8000 Merge pull request #15022 from meeseeksmachine/auto-backport-of-pr-15… · matplotlib/matplotlib@58b8472 · GitHub
[go: up one dir, main page]

Skip to content

Commit 58b8472

Browse files
authored
Merge pull request #15022 from meeseeksmachine/auto-backport-of-pr-15020-on-v3.1.x
Backport PR #15020 on branch v3.1.x (Let connectionpatch be drawn on figure level)
2 parents 4622afd + 8e65fee commit 58b8472

File tree

2 files changed

+17
-1
lines changed

2 files changed

+17
-1
lines changed

lib/matplotlib/patches.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4592,7 +4592,11 @@ def _check_xy(self, renderer):
45924592
if b or (b is None and self.coords1 == "data"):
45934593
x, y = self.xy1
45944594
xy_pixel = self._get_xy(x, y, self.coords1, self.axesA)
4595-
if not self.axes.contains_point(xy_pixel):
4595+
if self.axesA is None:
4596+
axes = self.axes
4597+
else:
4598+
axes = self.axesA
4599+
if not axes.contains_point(xy_pixel):
45964600
return False
45974601

45984602
if b or (b is None and self.coords2 == "data"):

lib/matplotlib/tests/test_patches.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -402,6 +402,18 @@ def test_connection_patch():
402402
ax2.add_artist(con)
403403

404404

405+
def test_connection_patch_fig():
406+
# Test that connection patch can be added as figure artist
407+
fig, (ax1, ax2) = plt.subplots(1, 2)
408+
xy = (0.3, 0.2)
409+
con = mpatches.ConnectionPatch(xyA=xy, xyB=xy,
410+
coordsA="data", coordsB="data",
411+
axesA=ax1, axesB=ax2,
412+
arrowstyle="->", shrinkB=5)
413+
fig.add_artist(con)
414+
fig.canvas.draw()
415+
416+
405417
def test_datetime_rectangle():
406418
# Check that creating a rectangle with timedeltas doesn't fail
407419
from datetime import datetime, timedelta

0 commit comments

Comments
 (0)
0