Skip to content

Commit 5bac860

Browse files
committed
FIX: Axes.indicate_inset failure
See #14275. inset_ax argument should be optional, but was failing because it tried to return a variable which was not defined. This is now fixed.
1 parent 608dc00 commit 5bac860

File tree

1 file changed

+10
-4
lines changed

1 file changed

+10
-4
lines changed

lib/matplotlib/axes/_axes.py

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -531,7 +531,8 @@ def indicate_inset(self, bounds, inset_ax=None, *, transform=None,
531531
Rectangle artist.
532532
533533
connector_lines : list of `.Patches.ConnectionPatch`
534-
One for each of four connector lines.
534+
One for each of four connector lines
535+
(empty if *inset_ax* is *None*).
535536
Two are set with visibility to *False*,
536537
but the user can set the visibility to *True* if the
537538
automatic choice is not deemed correct.
@@ -552,19 +553,24 @@ def indicate_inset(self, bounds, inset_ax=None, *, transform=None,
552553
zorder=zorder, label=label, transform=transform, **kwargs)
553554
self.add_patch(rectpatch)
554555

556+
connects = []
557+
555558
if inset_ax is not None:
556559
# want to connect the indicator to the rect....
557-
connects = []
558560
xr = [bounds[0], bounds[0]+bounds[2]]
559561
yr = [bounds[1], bounds[1]+bounds[3]]
560562
for xc in range(2):
561563
for yc in range(2):
562564
xyA = (xc, yc)
563565
xyB = (xr[xc], yr[yc])
564-
connects += [mpatches.ConnectionPatch(xyA, xyB,
566+
connects.append(
567+
mpatches.ConnectionPatch(
568+
xyA, xyB,
565569
'axes fraction', 'data',
566570
axesA=inset_ax, axesB=self, arrowstyle="-",
567-
zorder=zorder, edgecolor=edgecolor, alpha=alpha)]
571+
zorder=zorder, edgecolor=edgecolor, alpha=alpha
572+
)
573+
)
568574
self.add_patch(connects[-1])
569575
# decide which two of the lines to keep visible....
570576
pos = inset_ax.get_position()

0 commit comments

Comments
 (0)