【发布时间】:2019-01-27 21:39:48
【问题描述】:
我正在使用此代码进行绘图
def animate(i, xs, ys):
global a_depth
global b_depth
print(a_depth,b_depth)
if a_depth!=0 and b_depth!=0:
# Add x and y to lists
xs.append(dt.datetime.now().strftime('%H:%M:%S.%f'))
ys.append([a_depth, b_depth])
# Limit x and y lists to 20 items
# xs = xs[-20:]
# ys = ys[-20:]
# Draw x and y lists
ax.clear()
ax.plot(xs, ys)
ax.xaxis.set_major_formatter(plt.NullFormatter())
# Format plot
plt.xticks(rotation=45, ha='right')
plt.subplots_adjust(bottom=0.30)
plt.title('title')
plt.ylabel('ylabel')
# Set up plot to call animate() function periodically
ani = animation.FuncAnimation(fig, animate, fargs=(xs, ys), interval=1000)
plt.show()
我明白了:
如何隐藏红色圆圈内标记的黑线?由于这是一个动画情节,黑线不断堆积,使情节在拖动时滞后。
【问题讨论】:
-
@SiHa,当我如该答案所示调用 plt.tick_params() 时,它不起作用,仍然显示黑线
标签: python matplotlib