Matplotlib cannot create a graph

i like this post (click again to cancel)
0
i dont like this post (click again to cancel)

Hello! Using www.sagenb.com I typed the following code in the cell of my worksheet:

import matplotlib.pyplot as plt
plt.plot([1, 3, 2, 4])
plt.show()

Unfortunately there isn't any graph under the cell. What should I do? Thanks.

asked Jul 07 '12

AndreWin gravatar image AndreWin
23 1 2 7

updated Jul 07 '12

i like this answer (click again to cancel)
5
i dont like this answer (click again to cancel) AndreWin has selected this answer as correct

You just need to modify your last line.

import matplotlib.pyplot as plt
plt.plot([1, 3, 2, 4])
plt.savefig('test.png')

You might want to include x-coordinates to the get plot you want.

import matplotlib.pyplot as plt
plt.plot([1,2,3,4],[1, 3, 2, 4])
plt.savefig('test.png')

Also, you can get a nice plot in Sage with list_plot that might do the job for you.

link

posted Jul 07 '12

calc314 gravatar image calc314
1820 3 19 51

Thank you very much for you answer!

AndreWin (Jul 07 '12)

points(...) or line(...,linestyle='') are also good ideas.

kcrisman (Jul 07 '12)

Your answer

Please start posting your answer anonymously - your answer will be saved within the current session and published after you log in or create a new account. Please try to give a substantial answer, for discussions, please use comments and please do remember to vote (after you log in)!
[hide preview]

Question tools

1 follower

Tags:

Stats:

Asked: Jul 07 '12

Seen: 272 times

Last updated: Jul 07 '12

powered by ASKBOT version 0.7.22
Copyright Sage, 2010. Some rights reserved under creative commons license.