![](/img/trans.png)
[英]Dynamically update matplotlib figure in Jupyter notebook with Qt backend
[英]update matplotlib figure dynamically
我正在使用 matplotlib 绘制一些图形并动态更新它们,以便我使用 set_data 方法,如列出的代码所示
问题:当我需要为每一帧突出显示某个点时,旧的点仍然在图上
#display pics
fig,ax = plt.subplots(2,4)
im3 = ax[0][3].plot(x,y)[0]
#################################################
# some image processing code #
#################################################
plt.ion()
for pic_index in range(no_of_pics):
im3.set_ydata(smoothed_histogram)
#im3.set_data(threshold,smoothed_histogram[threshold],'g*')
ax[0][3].plot(threshold,smoothed_histogram[threshold],'r*')
ax[0][3].plot(effective_threshold,smoothed_histogram[effective_threshold],'r*')
plt.pause(0.01)
input("Press any key to continue...")
应该只有两个红点并更新每个循环
我怎样才能克服这个问题?
您upate的ydata
的smoothed_histogram
,你可以用你做同样的事情*
标记:
import numpy as np
import matplotlib.pyplot as plt
n = 100
x = np.arange(n)
y = np.sort(np.random.random(n))
fig, ax = plt.subplots()
ax.plot(x, y)
h_marker = ax.plot(x[0], y[0], marker='o', color='r')[0]
for i in range(n):
h_marker.set_data(x[i], y[i])
plt.pause(0.01)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.