Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

No plot window in matplotlib

I just installed matplotlib in Ubuntu 9.10 using the synaptic package system. However, when I try the following simple example

>>> from pylab import plot; >>> plot([1,2,3],[1,2,3]) [<matplotlib.lines.Line2D object at 0x9aa78ec>] 

I get no plot window. Any ideas on how to get the plot window to show?

like image 687
D R Avatar asked Jan 25 '10 08:01

D R


People also ask

Why is my matplotlib plot not showing?

It means if we are not using the show() function, it wouldn't show any plot. When we use the show() function in the non-interactive mode. That means when we write the code in the file it will show all the figures or plots and blocks until the plots have been closed.

Why is matplotlib Pyplot not working?

The ImportError: No module named matplotlib. pyplot occurs if you have not installed the Matplotlib library in Python and trying to run the script which has matplotlib related code. Another issue might be that you are not importing the matplotlib. pyplot properly in your Python code.

Why is my plot blank Python?

The reason your plot is blank is that matplotlib didn't auto-adjust the axis according to the range of your patches.


1 Answers

You can type

import pylab pylab.show() 

or better, use ipython -pylab.


Since the use of pylab is not recommended anymore, the solution would nowadays be

import matplotlib.pyplot as plt  plt.plot([1,2,3])  plt.show() 
like image 70
Peter Avatar answered Oct 14 '22 17:10

Peter