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?
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.
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.
The reason your plot is blank is that matplotlib didn't auto-adjust the axis according to the range of your patches.
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()
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With