ASKSAGE: Sage Q&A Forum - Individual question feedhttp://ask.sagemath.org/questions/Q&A Forum for SageenCopyright Sage, 2010. Some rights reserved under creative commons license.Thu, 25 Apr 2013 06:13:44 -0500matplotlib x11 windowhttp://ask.sagemath.org/question/10061/matplotlib-x11-window/In both Ipython and Python terminals I can type in the following
import matplotlib.pyplot as plt
plt.plot([1,2,3,4])
plt.ylabel('some numbers')
plt.show()
and a nice x11 figure will pop up (example figure is shown at http://matplotlib.org/users/pyplot_tutorial.html). In sage, the plt.show() statement just does nothing. Is there any way to make this work in sage? It is kindof neat at times that sage plotting functions just dump an image file and then launches an image viewer, but I need more primitive access to matplotlib sometimes and I also need to be able to interact with the figure sometimes. Why doesn't this work in the sage terminal?Wed, 24 Apr 2013 07:28:01 -0500http://ask.sagemath.org/question/10061/matplotlib-x11-window/Comment by vdelecroix for <p>In both Ipython and Python terminals I can type in the following</p>
<pre><code>import matplotlib.pyplot as plt
plt.plot([1,2,3,4])
plt.ylabel('some numbers')
plt.show()
</code></pre>
<p>and a nice x11 figure will pop up (example figure is shown at <a href="http://matplotlib.org/users/pyplot_tutorial.html">http://matplotlib.org/users/pyplot_tu...</a>). In sage, the plt.show() statement just does nothing. Is there any way to make this work in sage? It is kindof neat at times that sage plotting functions just dump an image file and then launches an image viewer, but I need more primitive access to matplotlib sometimes and I also need to be able to interact with the figure sometimes. Why doesn't this work in the sage terminal?</p>
http://ask.sagemath.org/question/10061/matplotlib-x11-window/?comment=17811#post-id-17811I confirm that it does work with my native Python and IPython. But it does not work with neither Python or IPython packed with Sage (obtained from the command line with "sage -python" or "sage -ipython")...Wed, 24 Apr 2013 08:13:45 -0500http://ask.sagemath.org/question/10061/matplotlib-x11-window/?comment=17811#post-id-17811Answer by Jesustc for <p>In both Ipython and Python terminals I can type in the following</p>
<pre><code>import matplotlib.pyplot as plt
plt.plot([1,2,3,4])
plt.ylabel('some numbers')
plt.show()
</code></pre>
<p>and a nice x11 figure will pop up (example figure is shown at <a href="http://matplotlib.org/users/pyplot_tutorial.html">http://matplotlib.org/users/pyplot_tu...</a>). In sage, the plt.show() statement just does nothing. Is there any way to make this work in sage? It is kindof neat at times that sage plotting functions just dump an image file and then launches an image viewer, but I need more primitive access to matplotlib sometimes and I also need to be able to interact with the figure sometimes. Why doesn't this work in the sage terminal?</p>
http://ask.sagemath.org/question/10061/matplotlib-x11-window/?answer=14840#post-id-14840For the cases in which you don't need interactivity, you can just change your
plt.show()
by a
plt.savefig('')
If you really want interactivity, you may find [this wiki page](http://wiki.sagemath.org/sage_matlab) useful (I haven't tried it myself, I must say).
Wed, 24 Apr 2013 14:09:15 -0500http://ask.sagemath.org/question/10061/matplotlib-x11-window/?answer=14840#post-id-14840Comment by Jesustc for <p>For the cases in which you don't need interactivity, you can just change your </p>
<pre><code>plt.show()
</code></pre>
<p>by a</p>
<pre><code>plt.savefig('')
</code></pre>
<p>If you really want interactivity, you may find <a href="http://wiki.sagemath.org/sage_matlab">this wiki page</a> useful (I haven't tried it myself, I must say).</p>
http://ask.sagemath.org/question/10061/matplotlib-x11-window/?comment=17808#post-id-17808Sorry, maybe I didn't understand it completely: do you want to do it from the command line or from the notebook? In the notebook, the savefig('') should work, while in the command line, in the worst case, you can always save the plot to a file and see it in any image viewer, with plt.savefig('some_path_and_file_name'). As for the wiki page, as I told you, I haven't tried it myself. Why don't you try to post the errors you get in the sage-support mailing list? (http://groups.google.com.au/group/sage-support)Thu, 25 Apr 2013 06:13:44 -0500http://ask.sagemath.org/question/10061/matplotlib-x11-window/?comment=17808#post-id-17808Comment by kjlvcxzoiperwq for <p>For the cases in which you don't need interactivity, you can just change your </p>
<pre><code>plt.show()
</code></pre>
<p>by a</p>
<pre><code>plt.savefig('')
</code></pre>
<p>If you really want interactivity, you may find <a href="http://wiki.sagemath.org/sage_matlab">this wiki page</a> useful (I haven't tried it myself, I must say).</p>
http://ask.sagemath.org/question/10061/matplotlib-x11-window/?comment=17809#post-id-17809plt.savefig('') didn't do anything, and i tried everything on the http://wiki.sagemath.org/sage_matlab link you provided, and that also didn't do anything.Thu, 25 Apr 2013 05:25:04 -0500http://ask.sagemath.org/question/10061/matplotlib-x11-window/?comment=17809#post-id-17809