Forums

ipython and matplotlib does not plot in console

Hi,

i just started my new account here to learn how to make nice data vizualizations.

My first lines in the ipython console were:

from pylab import *
plot(2,2)

I got an error for matplotlib

<matplotlib.lines.2D at 0x072....>

Why I got this error? Should I make a SSH connection and forward the website (free account) to my computer seing the plots?

Thank you in advance, Ela

[edited by admin: formatting]

Hi there,

See if this helps?

I've found it here: https://www.pythonanywhere.com/wiki/MatplotLibGraphs

But I do not like to save the picture and then call the picture. There exist some ipython directive I guess. I think, in the new jupyter version the matplot inline is also possible.

Is there a way in the nearest future to plot it in the console directly?

Hi there,

You won't be able to display graphics in the console, no. However, we are working on supporting ipython notebooks (ie. using jupyter hub). We cannot confirm the date this will be released yet though.

Hi,

sounds promising. Thanks for the information. I'll keep in touch with your site.

Once ipython notebooks are functional, you'll be able to have inline graphics.

Hi, I just wanted to find out if inline graphics are now possible?

They have always been possible in IPython notebooks.

hi Glenn, any news about this topic? I'm still not able to display pictures directly from the iPython reader with "plt.show()" :(

can you send us a screenshot of the error?

there is no error Harry, there is just no picture with the plt.show() function. I can see it with the save function but it would have been even better if I could see it directly in the Jupyter viewer..

OK, can you instead share some example code so I can try and reproduce the error?

Here it is:

plt.clf()
plt.ylim( -3, 3) 
plt.plot(t_instance[1:], time_series(t_instance[1:]), "b-", markersize=10, label="val A")
plt.plot(t_instance[1:], y[0,:,0], "g-", markersize=10, label="val B")
plt.legend(loc="upper left")
plt.xlabel("Time")

save_fig("plot" + project_title + str(iteration))
plt.show()

I'm going to need some actual data to put into those t_instance and time_series variables?

it doesn't work with any plot, for instance:

plt.plot([1,2,3,4], [1,4,9,16], 'ro')

plt.axis([0, 6, 0, 20])

plt.show()

To be clear - are you doing this in a notebook, or a console?

I'm doing it from the Pythonanywhere's Notebook.

I doesn't work also from a iPython console.

same is happening to me. Even if I use the %matplotlib magic in the Ipython Notebook.

what happens if you run

%pylab inline

before you do the plt.show()

it works :) thanks!

:-D