Ask Your Question
1

Matplotlib cannot create a graph

asked 2012-07-07 03:59:10 -0600

AndreWin gravatar image

updated 2012-07-07 04:01:00 -0600

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.

edit retag flag offensive close merge delete

1 answer

Sort by ยป oldest newest most voted
5

answered 2012-07-07 05:48:26 -0600

calc314 gravatar image

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.

edit flag offensive delete link more

Comments

Thank you very much for you answer!

AndreWin gravatar imageAndreWin ( 2012-07-07 06:50:51 -0600 )edit

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

kcrisman gravatar imagekcrisman ( 2012-07-07 16:12:54 -0600 )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: 2012-07-07 03:59:10 -0600

Seen: 1,605 times

Last updated: Jul 07 '12