Matplotlib and sage's python

72 views
Skip to first unread message

Julien Puydt

unread,
May 21, 2013, 3:51:57 PM5/21/13
to Sage Devel
Hi,

the following lines of python:
from pylab import *
xs = range(20)
ys = [x*x for x in xs]
plot(xs,ys)
show()

have a different outcome depending on where I type them:

- at the system python's prompt (just run 'python' then type them), I
get a window with the expected graph ;

- at sage's python's prompt (run './sage -python' then type them [tested
with 5.9 and 5.10.beta4), it just sits there.

What am I missing?

Snark on #sagemath

PS: searching for the issue on internet turns up many occurences of
people trying to do things in sage and even in sagenb -- I haven't found
someone trying to do that from sage's python directly.

William Stein

unread,
May 21, 2013, 3:57:44 PM5/21/13
to sage-devel@googlegroups.com sage-devel@googlegroups.com

Sage is by default built with any GUI support.

--
You received this message because you are subscribed to the Google Groups "sage-devel" group.
To unsubscribe from this group and stop receiving emails from it, send an email to sage-devel+unsubscribe@googlegroups.com.
To post to this group, send email to sage-...@googlegroups.com.
Visit this group at http://groups.google.com/group/sage-devel?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.


Julien Puydt

unread,
May 22, 2013, 2:30:07 AM5/22/13
to sage-...@googlegroups.com
Le 21/05/2013 21:57, William Stein a �crit :
> Sage is by default built with any GUI support.

Is there a non-default and easy way to get a working
matplotlib-on-bare-python?

Snark on #sagemath

John H Palmieri

unread,
May 22, 2013, 10:40:22 AM5/22/13
to sage-...@googlegroups.com


On Tuesday, May 21, 2013 11:30:07 PM UTC-7, Snark wrote:
Le 21/05/2013 21:57, William Stein a �crit :
> Sage is by default built with any GUI support.

Is there a non-default and easy way to get a working
matplotlib-on-bare-python?

 

You should check the matplotlib web pages; if I remember, they have pretty good documentation.

Meanwhile, you can also try installing Sage after setting then environment variable SAGE_MATPLOTLIB_GUI to "yes". In theory, that should build GUI support into matplotlb.

--
John

Benjamin Jones

unread,
May 22, 2013, 12:33:34 PM5/22/13
to sage-...@googlegroups.com
Without building GUI support, it should work to replace show() with savefig('plot.png'), for example. You won't get a window spawned with the plot, but an image on disk.

--
Benjamin Jones
benjami...@gmail.com


On Tue, May 21, 2013 at 11:30 PM, Julien Puydt <julien...@laposte.net> wrote:
Le 21/05/2013 21:57, William Stein a écrit :

Sage is by default built with any GUI support.

Is there a non-default and easy way to get a working matplotlib-on-bare-python?

Snark on #sagemath

Javier López Peña

unread,
May 22, 2013, 5:39:47 PM5/22/13
to sage-...@googlegroups.com
On Wednesday, May 22, 2013 7:30:07 AM UTC+1, Snark wrote:
Is there a non-default and easy way to get a working
matplotlib-on-bare-python?

Depending on your operating system getting matplotlib working over system python can be quite a tricky task, IIRC on Mac OSX 10.6 you must install some libraries (libpng, freetype( that conflict with their system-wide counterparts, and making everything use the right versions required some craft.

If you want a functional python/matplotlib without sage, one of the easiest ways I've found is using the anaconda bundle [1], a distribution similar in concept to sage but more oriented towards data analysis rather than pure math.

Hope this helps!

Cheers,
J



Julien Puydt

unread,
May 23, 2013, 1:10:36 AM5/23/13
to sage-...@googlegroups.com
Le 22/05/2013 23:39, Javier L�pez Pe�a a �crit :
My question wasn't precise enough, which explains why I get so many
different correct answers :-P

I wanted matplotlib-on-bare-python within sage, and John (Cremona)
answered to that part nicely.

But indeed, there exists other venues to get
python+numpy+scipy+matplotlib going on different operating system :
anaconda, winpython, direct installation of the bits... and the best is
to use a sane linux distribution like I do at home!

Thanks for all the answers!

Snark on #sagemath
Reply all
Reply to author
Forward
0 new messages