8000 Backport PR #15020 on branch v3.1.x (Let connectionpatch be drawn on figure level) by meeseeksmachine · Pull Request #15022 · matplotlib/matplotlib · GitHub
[go: up one dir, main page]

Skip to content

Backport PR #15020 on branch v3.1.x (Let connectionpatch be drawn on figure level) #15022

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

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

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion lib/matplotlib/patches.py
Original file line number Diff line number Diff line change
Expand Up @@ -4592,7 +4592,11 @@ def _check_xy(self, renderer):
if b or (b is None and self.coords1 == "data"):
x, y = self.xy1
xy_pixel = self._get_xy(x, y, self.coords1, self.axesA)
if not self.axes.contains_point(xy_pixel):
if self.axesA is None:
axes = self.axes
else:
axes = self.axesA
if not axes.contains_point(xy_pixel):
return False

if b or (b is None and self.coords2 == "data"):
Expand Down
12 changes: 12 additions & 0 deletions lib/matplotlib/tests/test_patches.py
Original file line number Diff line number Diff line change
Expand Up @@ -402,6 +402,18 @@ def test_connection_patch():
ax2.add_artist(con)


def test_connection_patch_fig():
# Test that connection patch can be added as figure artist
fig, (ax1, ax2) = plt.subplots(1, 2)
xy = (0.3, 0.2)
con = mpatches.ConnectionPatch(xyA=xy, xyB=xy,
coordsA="data", coordsB="data",
axesA=ax1, axesB=ax2,
arrowstyle="->", shrinkB=5)
fig.add_artist(con)
fig.canvas.draw()


def test_datetime_rectangle():
# Check that creating a rectangle with timedeltas doesn't fail
from datetime import datetime, timedelta
Expand Down
0