Ask Your Question
0

matplotlib x11 window

asked 11 years ago

kjlvcxzoiperwq gravatar image

updated 11 years ago

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?

Preview: (hide)

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 ( 11 years ago )

1 Answer

Sort by » oldest newest most voted
2

answered 11 years ago

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

Preview: (hide)
link

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 ( 11 years ago )

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 ( 11 years ago )

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: 11 years ago

Seen: 1,332 times

Last updated: Apr 24 '13