When I am in an interactive python session (usually IPython), the following commands:
from matplotlib import pyplot as plt
plt.plot([1,2,3,4])
do not auto开发者_StackOverflow社区matically raise a window, showing the plot. The only way I can make matplotlib actually raise the window is using show()
, which also captures all input until I close the window destroying the plot. Now I have to give all my plot commands before I can see any result, which is a major nuisance. On OSX, I do not have this issue.
The backend I'm using is TkAgg. Using draw()
and ion()
calls has no effect.
If you use IPython pylab mode, this works:
In [1]: plot([1,2,3,4])
Out[1]: [<matplotlib.lines.Line2D object at 0x020F75B0>]
there is not need for show() nor matplotlib import.
In IPython normal mode you can make your session interactive. This also works:
In [4]: from matplotlib import interactive
In [5]: interactive(True)
In [6]: from matplotlib import pyplot as plt
In [7]: plt.plot([1,2,3,4])
Out[7]: [<matplotlib.lines.Line2D object at 0x00F89D50>]
精彩评论