matplotlib / matplotlib Public
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix drawing animated artists changed in selector callback #21342
base: main
Are you sure you want to change the base?
Fix drawing animated artists changed in selector callback #21342
Conversation
|
I like the general approach more here. |
|
Yes, I agree, this is much better! :) |
b6475bc
to
515aa53
|
In 515aa53, I remove the Adapting one of the blitting example: import matplotlib.pyplot as plt
from matplotlib.widgets import SpanSelector
import numpy as np
x = np.linspace(0, 2 * np.pi, 100)
values = np.sin(x)
fig, ax = plt.subplots()
(ln,) = ax.plot(x, values, animated=True)
(ln2 , ) = ax.plot([], animated=True)
plt.show(block=False)
plt.pause(0.1)
bg = fig.canvas.copy_from_bbox(fig.bbox)
ax.draw_artist(ln)
fig.canvas.blit(fig.bbox)
def mean(vmin, vmax):
indmin, indmax = np.searchsorted(x, (vmin, vmax))
v = values[indmin:indmax].mean()
ln2.set_data(x, v)
span = SpanSelector(ax, mean, direction='horizontal',
onmove_callback=mean,
interactive=True,
drag_from_anywhere=True,
useblit=True) |
453b4cd
to
1e988b3
|
I have added a test and switch to list comprehension instead of using filter. |
|
2a5c86c fixes an issue with zorder of the artists. Before 2a5c86c, the selector artists will be drawn before other artists and therefore it was behind, as in the following example: import matplotlib.pyplot as plt
from matplotlib.widgets import SpanSelector
import numpy as np
values = np.ones((10, 10))
fig, ax = plt.subplots()
ax.imshow(values, animated=True)
span = SpanSelector(ax, print, direction='horizontal',
interactive=True,
drag_from_anywhere=True,
useblit=True)when sorting the artists order, all artists need to sorted together! |
|
@dstansby, any chance you can have a look at this again, please? Thanks! |
|
This PR is affected by a re-writing of our history to remove a large number of accidentally committed files see discourse for details. To recover this PR it will need be rebased onto the new default branch (main). There are several ways to accomplish this, but we recommend (assuming that you call the matplotlib/matplotlib remote git remote update
git checkout main
git merge --ff-only upstream/main
git checkout YOUR_BRANCH
git rebase --onto=main upstream/old_master
# git rebase -i main # if you prefer
git push --force-with-lease # assuming you are tracking your branchIf you do not feel comfortable doing this or need any help please reach out to any of the Matplotlib developers. We can either help you with the process or do it for you. Thank you for your contributions to Matplotlib and sorry for the inconvenience. |
991cdb6
to
67f6c90
67f6c90
to
a189593
|
Can anyone review this PR, please? |
|
@dstansby, if this PR looks good to you - from your comment in #21342 (review); can you please approve and merge? :) Thanks! |


PR Summary
Alternative to #20977.
PR Checklist
pytestpasses).flake8on changed files to check).flake8-docstringsand runflake8 --docstring-convention=all).doc/users/next_whats_new/(follow instructions in README.rst there).doc/api/next_api_changes/(follow instructions in README.rst there).The text was updated successfully, but these errors were encountered: