I am plotting with this code
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()
And I get this:
How do I hide the black lines marked inside the red circle? Since this is an animated plot, the black lines keep piling up making the plot to lag when dragging it around.