ASKSAGE: Sage Q&A Forum - RSS feedhttps://ask.sagemath.org/questions/Q&A Forum for SageenCopyright Sage, 2010. Some rights reserved under creative commons license.Mon, 14 Apr 2014 03:57:53 +0200GUI backend MATPLOTLIB in Sagehttps://ask.sagemath.org/question/11347/gui-backend-matplotlib-in-sage/Dear all,
- UPDATED:
How can one **export** the data (a object) 'matplotlib.figure.Figure' the namespace of Sagemath to IPython? Can the data be saved in a format (**not** png, pdf, etc.) that can be opened in IPython using the function **show()**?
Here is a related [Question](http://ask.sagemath.org/question/816/how-to-use-tk-on-sage). I have followed [this instruction](http://wiki.sagemath.org/sage_matlab) step by step, every step was successfully executed without any error report/message. However I couldn't invoke TkAgg as Backend of Sagemath nor IPython.
----------
Has SAGE a GUI back-end as MATPLOTLIB, on which one can **zoom, select points** etc.?
for example,
sage: bodes['entire']
<matplotlib.figure.Figure at 0x91ac950>
sage: bodes['entire'].show()
# It doesn't work and a Warning occurs.
/opt/sagemath/sage-6.1.1-x86_64-Linux/local/lib/python2.7/
site-packages/matplotlib/figure.py:362: UserWarning: matplotlib is
currently using a non-GUI backend, so cannot show the figure
"matplotlib is currently using a non-GUI backend, "
sage: f = bodes['entire']
sage: f.savefig('./figures/entire.png')
# I can only save my plotting in formats : png, pdf, etc..
----------
Thank you all in advance!
Tue, 25 Mar 2014 06:45:29 +0100https://ask.sagemath.org/question/11347/gui-backend-matplotlib-in-sage/Comment by vdelecroix for <p>Dear all,</p>
<ul>
<li>UPDATED:</li>
</ul>
<p>How can one <strong>export</strong> the data (a object) 'matplotlib.figure.Figure' the namespace of Sagemath to IPython? Can the data be saved in a format (<strong>not</strong> png, pdf, etc.) that can be opened in IPython using the function <strong>show()</strong>? </p>
<p>Here is a related <a href="http://ask.sagemath.org/question/816/how-to-use-tk-on-sage">Question</a>. I have followed <a href="http://wiki.sagemath.org/sage_matlab">this instruction</a> step by step, every step was successfully executed without any error report/message. However I couldn't invoke TkAgg as Backend of Sagemath nor IPython.</p>
<hr/>
<p>Has SAGE a GUI back-end as MATPLOTLIB, on which one can <strong>zoom, select points</strong> etc.? </p>
<p>for example,</p>
<pre><code> sage: bodes['entire']
<matplotlib.figure.Figure at 0x91ac950>
sage: bodes['entire'].show()
# It doesn't work and a Warning occurs.
/opt/sagemath/sage-6.1.1-x86_64-Linux/local/lib/python2.7/
site-packages/matplotlib/figure.py:362: UserWarning: matplotlib is
currently using a non-GUI backend, so cannot show the figure
"matplotlib is currently using a non-GUI backend, "
sage: f = bodes['entire']
sage: f.savefig('./figures/entire.png')
# I can only save my plotting in formats : png, pdf, etc..
</code></pre>
<hr/>
<p>Thank you all in advance!</p>
https://ask.sagemath.org/question/11347/gui-backend-matplotlib-in-sage/?comment=16211#post-id-16211Only steps 6 to 9 are important because by default matplotlib is built without GUI support within Sage. It worked for me. Try again with removing all related to TkAgg.Thu, 27 Mar 2014 16:55:49 +0100https://ask.sagemath.org/question/11347/gui-backend-matplotlib-in-sage/?comment=16211#post-id-16211Comment by vdelecroix for <p>Dear all,</p>
<ul>
<li>UPDATED:</li>
</ul>
<p>How can one <strong>export</strong> the data (a object) 'matplotlib.figure.Figure' the namespace of Sagemath to IPython? Can the data be saved in a format (<strong>not</strong> png, pdf, etc.) that can be opened in IPython using the function <strong>show()</strong>? </p>
<p>Here is a related <a href="http://ask.sagemath.org/question/816/how-to-use-tk-on-sage">Question</a>. I have followed <a href="http://wiki.sagemath.org/sage_matlab">this instruction</a> step by step, every step was successfully executed without any error report/message. However I couldn't invoke TkAgg as Backend of Sagemath nor IPython.</p>
<hr/>
<p>Has SAGE a GUI back-end as MATPLOTLIB, on which one can <strong>zoom, select points</strong> etc.? </p>
<p>for example,</p>
<pre><code> sage: bodes['entire']
<matplotlib.figure.Figure at 0x91ac950>
sage: bodes['entire'].show()
# It doesn't work and a Warning occurs.
/opt/sagemath/sage-6.1.1-x86_64-Linux/local/lib/python2.7/
site-packages/matplotlib/figure.py:362: UserWarning: matplotlib is
currently using a non-GUI backend, so cannot show the figure
"matplotlib is currently using a non-GUI backend, "
sage: f = bodes['entire']
sage: f.savefig('./figures/entire.png')
# I can only save my plotting in formats : png, pdf, etc..
</code></pre>
<hr/>
<p>Thank you all in advance!</p>
https://ask.sagemath.org/question/11347/gui-backend-matplotlib-in-sage/?comment=16202#post-id-16202You can try to use http://www.math.uiuc.edu/~nmd//temp/tkplot.pyMon, 14 Apr 2014 03:44:58 +0200https://ask.sagemath.org/question/11347/gui-backend-matplotlib-in-sage/?comment=16202#post-id-16202Answer by vdelecroix for <p>Dear all,</p>
<ul>
<li>UPDATED:</li>
</ul>
<p>How can one <strong>export</strong> the data (a object) 'matplotlib.figure.Figure' the namespace of Sagemath to IPython? Can the data be saved in a format (<strong>not</strong> png, pdf, etc.) that can be opened in IPython using the function <strong>show()</strong>? </p>
<p>Here is a related <a href="http://ask.sagemath.org/question/816/how-to-use-tk-on-sage">Question</a>. I have followed <a href="http://wiki.sagemath.org/sage_matlab">this instruction</a> step by step, every step was successfully executed without any error report/message. However I couldn't invoke TkAgg as Backend of Sagemath nor IPython.</p>
<hr/>
<p>Has SAGE a GUI back-end as MATPLOTLIB, on which one can <strong>zoom, select points</strong> etc.? </p>
<p>for example,</p>
<pre><code> sage: bodes['entire']
<matplotlib.figure.Figure at 0x91ac950>
sage: bodes['entire'].show()
# It doesn't work and a Warning occurs.
/opt/sagemath/sage-6.1.1-x86_64-Linux/local/lib/python2.7/
site-packages/matplotlib/figure.py:362: UserWarning: matplotlib is
currently using a non-GUI backend, so cannot show the figure
"matplotlib is currently using a non-GUI backend, "
sage: f = bodes['entire']
sage: f.savefig('./figures/entire.png')
# I can only save my plotting in formats : png, pdf, etc..
</code></pre>
<hr/>
<p>Thank you all in advance!</p>
https://ask.sagemath.org/question/11347/gui-backend-matplotlib-in-sage/?answer=16112#post-id-16112I am just repeating the solution of N. Dunfield at [http://www.math.uiuc.edu/~nmd/temp/tkplot.py](http://www.math.uiuc.edu/~nmd/temp/tkplot.py) for backup
Matplotlib does all the 2D graphics for Sage, but unfortunately none of
its GUI backends are compiled by default. The following suffices to
compile the Tk backend on Linux, provided you have the tk-dev(el)
package installed:
$ export SAGE_MATPLOTLIB_GUI=yes
$ sage -f matplotlib
This doesn't work on OS X because in addition to TkAgg, Sage will try to
compile the native Mac backend, which fails since Sage doesn't include
an Objective-C compiler. For OS X, download the source tarball for
matplotlib, and then do
$ cd matplotlib-*
$ sage -sh echo '[gui_support]' >> setup.cfg
$ echo 'macosx=false' >> setup.cfg
$ python setup.py install
Alternatively use the patched spkg (which has a modified
make-setup-config.py file at the top leve ) available at http://dunfield.info/temp/matplotlib-1.2.1.spkg
Note that the TkAgg backend will be compiled against one's current
version of Tk, which might not be the one that Sage is linked against.
So inaddition one may need to recompile the Tkinter module via
$ sage -f python
Then any matplotlib command will work:
sage: from numpy import arange, sin, pi
sage: import matplotlib.pyplot as plt
sage: X = arange(0.0, 2*pi, 0.01)
sage: plt.plot(X, sin(X))
sage: plt.show()
Something seems to be broken since version 5.11, the GUI blocks the console. In order to correct this behaviour one solution is to use the following (see also [#15152](http://trac.sagemath.org/ticket/15152)):
sage: import IPython.lib.inputhook as ih
sage: ih.clear_inputhook()
Note that after that command, the magic %attach will be broken.Mon, 14 Apr 2014 03:57:53 +0200https://ask.sagemath.org/question/11347/gui-backend-matplotlib-in-sage/?answer=16112#post-id-16112