Reputation: 4855
I don’t know why my matplotlib didn’t show plots, and no errors too. I thinks I missing something on its installation because when in IPython notebooks an QtIpython using %mayplotlib inline
directive have no problems but when running from terminal or script didn’t show anything. Any ideas ??
for example, in QtIPython and Ipython notebook I run
%matplotlib inline
import matplotlib.pyplot as plt
fig = plt.figure()
ax = fig.add_subplot(111, aspect='equal')
ax.plot([1,2,3,4,5,6,7,8,9,0],[2,3,4,5,6,7,8,9,0,11], '-r')
ax.grid()
plt.show()
and the plot shows Ok!
but in a simple script with
import matplotlib.pyplot as plt
fig = plt.figure()
ax = fig.add_subplot(111, aspect='equal')
ax.plot([1,2,3,4,5,6,7,8,9,0],[2,3,4,5,6,7,8,9,0,11], '-r')
ax.grid()
plt.show()
didn’t show anything
Upvotes: 1
Views: 5699
Reputation: 1813
If you use matplotlib inline in IPython notebook, the plots are shown automatically. If you plot things in a script you have to put a plt.show()
at the end to actually show the figure. In the terminal you can also use plt.ion()
to switch on intreactive mode.
Upvotes: 5