Ask Your Question
0 and plt.draw() doesnt work

asked 2014-07-12 11:52:36 -0600

mresimulator gravatar image

updated 2014-07-13 10:28:47 -0600

Hi experts!

I have a numpy array M. I generate a graph using NetworkX and then I want to draw this graph:

import networkx as nx
import matplotlib.pyplot as plt

Doing this, no picture appears. In addition, if I do no picture appears neither.

If I do

import numpy as np
import matplotlib.pyplot as plt
x = np.range(0, 5, 0.1);
y = np.sin(x)
plt.plot(x, y)

no picture appears neither.

What happend?

Please help!

Best regards

edit retag flag offensive close merge delete

1 answer

Sort by ยป oldest newest most voted

answered 2014-07-12 18:26:55 -0600

calc314 gravatar image

Try using plt.figure() before your set up the plot. For example, the following works for me in SMC:

edit flag offensive delete link more


Thanks calc314. If I do plt.savefig('lalala.png') the picture is generated and saved, but if I do no picture appears. I try to do this:, but I cant save changes in the file matplotlibrc. Please help. Thanks a lot

mresimulator gravatar imagemresimulator ( 2014-07-13 10:48:40 -0600 )edit

How are you running Sage? In a SageMathCloud worksheet, sagenb worksheet, or on the command line?

calc314 gravatar imagecalc314 ( 2014-07-13 12:41:10 -0600 )edit

Also, did you try `fig=plt.figure()` prior to your draw command?

calc314 gravatar imagecalc314 ( 2014-07-13 12:41:42 -0600 )edit

Yes, im running SAGE in my PC (not in SMC), just in the command line. I tried 'fig=plt.figure()' without good results.

mresimulator gravatar imagemresimulator ( 2014-07-14 18:56:20 -0600 )edit

If you are running it on the command line, I'm not sure Sage will be able to pop open a graphics window, esp. in Windows. Your best bet might be to make a system call in your Sage code and ask the OS to open the graphics file.

calc314 gravatar imagecalc314 ( 2014-07-22 07:40:31 -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


Asked: 2014-07-12 11:52:36 -0600

Seen: 1,793 times

Last updated: Jul 13 '14