Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Updating a plot doesn't clear old plots, if event trigger came from another figure? #10183

Closed
Labels
@clsmt

Description

@clsmt

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

image

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:

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions


      [8]ページ先頭

      ©2009-2025 Movatter.jp