多次显示绘图窗口 [英] Showing the plot window more than once

查看:31
本文介绍了多次显示绘图窗口的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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:

如果我关闭图形窗口,并再次运行最后一行 (>>>pylab.show(plotting)),图形将不会再次弹出.为什么会这样?上面的代码在Python 2.7.3中运行.

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.

推荐答案

因为当您关闭窗口时python会拆下并删除图形.再次调用 show 没有任何作用,因为没有要显示的数字.

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.

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.

这篇关于多次显示绘图窗口的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆