Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork7.9k
Closed
Description
Bug report
Bug summary
I am updating a line plot. There is an event trigger that starts this updating. If the trigger came from the figure that contains the plot, everything is fine. However, if the trigger came from another figure, then weird results happen: the line that's been updated appears to leave its trace uncleared.
Code for reproduction
importmatplotlib.pyplotaspltimportnumpyasnpdefonclick(event):foriiinnp.linspace(0.,np.pi,100):y1=y*np.sin(ii)line1.set_ydata(y1)ax.draw_artist(line1)line2.set_ydata(-y1)ax2.draw_artist(line2)ax2.set_ylim(y1.min(),y1.max())fig.canvas.update()plt.pause(0.1)x=np.linspace(0.,2*np.pi,100)y=np.sin(x)fig=plt.figure()ax=fig.add_subplot(1,2,1)line1=ax.plot(x,y)[0]ax2=fig.add_subplot(1,2,2)line2=ax2.plot(x,y)[0]fig2=plt.figure()cid=fig2.canvas.mpl_connect('button_press_event',onclick)# cid = fig.canvas.mpl_connect('button_press_event', onclick)plt.show()
Actual outcome
Expected outcome
Not the many curves saw in the above figure, just one curve being updated in each cycle. In the code snippet, if use
cid = fig.canvas.mpl_connect('button_press_event', onclick)
then it works as intended.
Also note, if you resize the plot, or save it as figure, then all the residue curves will be gone.
Matplotlib version
- Operating system: windows
- Matplotlib version: 2.0.0
- Matplotlib backend (
print(matplotlib.get_backend())
): Qt4Agg - Python version: 2.7
- Jupyter version (if applicable):
- Other libraries: