FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

Fix: Prevent Cursor blitting from erasing overlapping axes (#25670) by MohitPal2005 · Pull Request #31368 · matplotlib/matplotlib · GitHub

Repository navigation

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension .py  (2) All 1 file type selected
Viewed files
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Unified
Split
Hide whitespace
Diff view
Unified
Split
Hide whitespace
16 changes: 16 additions & 0 deletions lib/matplotlib/tests/test_widgets.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
Expand Up @@ -1817,3 +1817,19 @@ def test_parent_axes_removal():
evt = DrawEvent('draw_event', fig.canvas, renderer)
radio._clear(evt)
checks._clear(evt)


def test_cursor_overlapping_axes_blitting_warning():
"""Test that a warning is raised and useblit is disabled for overlapping axes."""
fig = plt.figure()
ax1 = fig.add_axes([0.1, 0.1, 0.8, 0.8])
ax2 = fig.add_axes([0.2, 0.2, 0.6, 0.6]) # Explicitly overlaps ax1

match_text = (
"Cursor blitting is currently not supported on "
"overlapping axes"
)
with pytest.warns(UserWarning, match=match_text):
cursor = widgets.Cursor(ax1, useblit=True)

assert cursor.useblit is False
10 changes: 10 additions & 0 deletions lib/matplotlib/widgets.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
Expand Up @@ -2084,6 +2084,16 @@ def __init__(self, ax, *, horizOn=True, vertOn=True, useblit=False,
self.vertOn = vertOn
self.useblit = useblit and self.canvas.supports_blit # TODO: make dynamic

if self.useblit:
for ax_ in ax.get_figure(root=True).get_axes():
if ax_ is not ax and ax.bbox.overlaps(ax_.bbox):
_api.warn_external(
"Cursor blitting is currently not supported on "
"overlapping axes; falling back to useblit=False."
)
self.useblit = False
break

if self.useblit:
lineprops['animated'] = True
self.lineh = ax.axhline(ax.get_ybound()[0], visible=False, **lineprops)
Expand Down
Loading

Back | FazBrowse Home | New Git URL