Ask Your Question
0

matplotlib x11 window

asked 2013-04-24 14:28:01 +0100

kjlvcxzoiperwq gravatar image

updated 2013-05-11 15:45:39 +0100

vdelecroix gravatar image

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_tu...). 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?

edit retag flag offensive close merge delete

Comments

I 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")...

vdelecroix gravatar imagevdelecroix ( 2013-04-24 15:13:45 +0100 )edit

1 Answer

Sort by ยป oldest newest most voted
2

answered 2013-04-24 21:09:15 +0100

Jesustc gravatar image

For 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 useful (I haven't tried it myself, I must say).

edit flag offensive delete link more

Comments

plt.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.

kjlvcxzoiperwq gravatar imagekjlvcxzoiperwq ( 2013-04-25 12:25:04 +0100 )edit

Sorry, 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)

Jesustc gravatar imageJesustc ( 2013-04-25 13:13:44 +0100 )edit

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

1 follower

Stats

Asked: 2013-04-24 14:28:01 +0100

Seen: 1,274 times

Last updated: Apr 24 '13