Showing the plot window more than once

走远了吗. 提交于 2019-12-19 10:41:27

问题


import matplotlib
import pylab
x=[1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
y=[2, 4, 6, 8, 10, 12, 14, 16, 18, 20]
plotting=pylab.plot(x,y)
pylab.show(plotting)

The code above (specifically the last line) would pop up the graph below:

If I close the graph window, and run the last line (>>>pylab.show(plotting)) again, the graph would not pop up again. Why is that so? The code above was run in Python 2.7.3.


回答1:


Because when you close the window python tears down and deletes the figure. Calling show again does nothing because there is no figure to show.

Passing an arguement to show like you do here does nothing (doc). The only argument that show takes is a key-word argument of block.



来源:https://stackoverflow.com/questions/15724747/showing-the-plot-window-more-than-once

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!