8000 Let connectionpatch be drawn on figure level (#15020) · matplotlib/matplotlib@6f4dd80 · GitHub
[go: up one dir, main page]

Skip to content

Commit 6f4dd80

Browse files
authored
Let connectionpatch be drawn on figure level (#15020)
Let connectionpatch be drawn on figure level
2 parents 1f003b0 + 03c88e8 commit 6f4dd80

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
@@ -4454,7 +4454,11 @@ def _check_xy(self, renderer):
44544454
if b or (b is None and self.coords1 == "data"):
44554455
x, y = self.xy1
44564456
xy_pixel = self._get_xy(x, y, self.coords1, self.axesA)
4457-
if not self.axes.contains_point(xy_pixel):
4457+
if self.axesA is None:
4458+
axes = self.axes
4459+
else:
4460+
axes = self.axesA
4461+
if not axes.contains_point(xy_pixel):
44584462
return False
44594463

44604464
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
@@ -396,6 +396,18 @@ def test_connection_patch():
396396
ax2.add_artist(con)
397397

398398

399+
def test_connection_patch_fig():
400+
# Test that connection patch can be added as figure artist
401+
fig, (ax1, ax2) = plt.subplots(1, 2)
402+
xy = (0.3, 0.2)
403+
con = mpatches.ConnectionPatch(xyA=xy, xyB=xy,
404+
coordsA="data", coordsB="data",
405+
axesA=ax1, axesB=ax2,
406+
arrowstyle="->", shrinkB=5)
407+
fig.add_artist(con)
408+
fig.canvas.draw()
409+
410+
399411
def test_datetime_rectangle():
400412
# Check that creating a rectangle with timedeltas doesn't fail
401413
from datetime import datetime, timedelta

0 commit comments

Comments
 (0)