On Monday, November 19, 2012 1:21:28 PM UTC+7, P Purkayastha wrote:
> On 11/19/2012 10:41 AM, Eric Verner wrote:
> 
> > When I try to plot data using matplotlib from the sage command line using 
> > show(), nothing happens. I have done some research and tried several 
> > different backends to matplotlib in the matplotlibrc file, including Cairo, 
> > GTK, WX, Agg, and MacOSX, and nothing works. I have tried to install pygtk 
> > and pycairo to Sage with no luck. Can someone give me a concise, 
> > straightforward way to get show() to work on my computer (Mac OS X 10.6.8). 
> > I would be very grateful. Thanks.
> 
> >
> 
> 
> 
> You can't, AFAIK. Matplotlib figures are not Sage objects. When you use 
> 
> show(some_figure), it usually calls some_figure.show() which is a Sage 
> 
> method.
> 
> 
> 
> One option for you would be to declare a simple class which takes a 
> 
> matplotlib object and which has a show() method. In the show() method 
> 
> you can save your figure to some temporary file and then call some image 
> 
> viewer to view the file. This applies only for the command line. Look at 
> 
> the very end of the output when you run the following commands, on how 
> 
> to call your image viewer:
> 
> sage: p = Graphics()
> 
> sage: p.show??
> 
> 
> 
> Also, ticket #5128 would be of interest to you:
> 
> http://trac.sagemath.org/5128
> 
> 
> 
> 
> 
> On a notebook, you simply need to save the figure and it will 
> 
> automatically be shown on the cell output. So, you would do:
> 
> 
> 
> <do all your matplotlib commands>
> 
> <let's suppose, for simplicity you were using pyplot>
> 
> plt.savefig('./figure.png')
> 
> 
> 
> and it will show up in your cell output.

P,
Thanks a lot for your suggestions. Yea, figuring this out seemed way too hard. 
I guess I'm not surprised that there is no way to do this. I am using Agg now, 
which saves the file. I started using Notebook(), and it is a really nice 
interface for writing code. I am somewhat surprised that Sage doesn't include a 
standard way to do this. I can plot lists using the standard Sage plot 
function, so I found it odd that I couldn't do the same with numpy arrays. If 
Sage could create interactive figures that were similar to Matlab figures, that 
would be pretty awesome. I took a look at the other ticket you suggested, and I 
will try it out.

Thanks!
Eric

-- 
You received this message because you are subscribed to the Google Groups 
"sage-devel" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
Visit this group at http://groups.google.com/group/sage-devel?hl=en.


Reply via email to