Ask Your Question
1

Matplotlib cannot create a graph

asked 2012-07-07 10:59:10 +0100

AndreWin gravatar image

updated 2012-07-07 11:01:00 +0100

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 12:48:26 +0100

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 13:50:51 +0100 )edit

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

kcrisman gravatar imagekcrisman ( 2012-07-07 23:12:54 +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: 2012-07-07 10:59:10 +0100

Seen: 1,987 times

Last updated: Jul 07 '12