I need your help about matplotlib. Yes, I did not forget calling the pyplot.show().
$ ipython --pylab
import matplotlib.pyplot as p
p.plot(range(20), range(20))
It returns matplotlib.lines.Line2D at 0xade2b2c
as the output.
p.show()
There is nothing to happen. No error message. No new window. Nothing. I install matplotlib
by using pip and I didn't take any error messages.
Details:
I use,
- Ubuntu
- IPython v0.11
- Python v2.6.6
- matplotlib v1.0.1
Be sure to have this startup script enabled : ( Preferences > Console > Advanced Options )
If the standard PYTHONSTARTUP is enabled you won't have an interactive plot
Adding the following two lines before importing pylab seems to work for me
If I set my backend to
template
in~/.matplotlib/matplotlibrc
, then I can reproduce your symptoms:~/.matplotlib/matplotlibrc:
Note that the file
matplotlibrc
may not be in directory~/.matplotlib/
. In this case, the following code shows where it is:If you edit
~/.matplotlib/matplotlibrc
and change the backend to something likeGtkAgg
, you should see a plot. You can list all the backends available on your machine withIt should return a list like:
Reference:
What solved my problem was just using the below two lines in ipython notebook at the top
And it worked. I'm using Ubuntu16.04 and ipython-5.1
For future reference,
I have encountered the same problem -- pylab was not showing under ipython. The problem was fixed by changing ipython's config file {ipython_config.py}. In the config file
c.InteractiveShellApp.pylab = 'auto'
I changed 'auto' to 'qt' and now I see graphs
Just type:
plt.ion()
See https://www.youtube.com/watch?v=1zmV8lZsHF4 at 23:30 !
plt
is used because of my import:import matplotlib.pyplot
as pltI'm using python2.7 on a mac with iTerm2.