Python使用matplotlib来for循环实时画图为什么会出现多个图出来,循环几次就出来几个图,什么原因?

Python021

Python使用matplotlib来for循环实时画图为什么会出现多个图出来,循环几次就出来几个图,什么原因?,第1张

你好,你的代码里面用了一个for循环来调用plot.scatter,一共调用了三次,所以画了三个图。

你可以考虑用下面的代码:

x=[]

Y=[]

for i in range(3):

x.append(i)

y=np.random.random()

Y.append(y)

plt.scatter(x,Y)

ply.show()

Matplotlib

速度慢,适用于绘制高质量的图像,但不适用于快速的实时绘图。PyQtGraph官网

对此评论为:If you are doing anything requiring rapid plot updates, video, or

realtime interactivity, matplotlib is not the best choice.

PyQwt

不支持PyQt5,还有就是不再维护了,PyQtGraph官网

对此评论为:Its main drawback is that it is currently unmaintained and can be

difficult to get working on a variety of platforms. Hopefully in the

future it may find a new maintainer, but until then it may be best to

avoid PyQwt.

PyQtGraph

使用Python编写,支持PyQt4和PyQt5,最新发布版本为0.10.0停留在2016年。

PythonQwt

使用Python编写,支持PyQt4和PyQt5,PythonQwt的GitHub主页

对此介绍为:The PythonQwt package is a 2D-data plotting library using Qt

graphical user interfaces for the Python programming language. It is

compatible with both PyQt4 and PyQt5.

guiqwt

和PythonQwt是同一作者,基于PythonQwt做了功能扩展,最新发布版本为3.0.3停留在2016年。