@@ -530,9 +530,12 @@ def indicate_inset(self, bounds, inset_ax=None, *, transform=None,
530
530
rectangle_patch : `.Patches.Rectangle`
531
531
Rectangle artist.
532
532
533
- connector_lines : 4-tuple of `.Patches.ConnectionPatch`
534
- One for each of four connector lines. Two are set with visibility
535
- to *False*, but the user can set the visibility to True if the
533
+ connector_lines : optional 4-tuple of `.Patches.ConnectionPatch`
534
+ Each of four connector lines coming from the given rectangle
535
+ on this axes in the order lower left, upper left, lower right,
536
+ upper right: *None* if *inset_ax* is *None*.
537
+ Two are set with visibility to *False*,
538
+ but the user can set the visibility to *True* if the
536
539
automatic choice is not deemed correct.
537
540
538
541
"""
@@ -551,19 +554,24 @@ def indicate_inset(self, bounds, inset_ax=None, *, transform=None,
551
554
zorder = zorder , label = label , transform = transform , ** kwargs )
552
555
self .add_patch (rectpatch )
553
556
557
+ connects = []
558
+
554
559
if inset_ax is not None :
555
560
# want to connect the indicator to the rect....
556
- connects = []
557
561
xr = [bounds [0 ], bounds [0 ]+ bounds [2 ]]
558
562
yr = [bounds [1 ], bounds [1 ]+ bounds [3 ]]
559
563
for xc in range (2 ):
560
564
for yc in range (2 ):
561
565
xyA = (xc , yc )
562
566
xyB = (xr [xc ], yr [yc ])
563
- connects += [mpatches .ConnectionPatch (xyA , xyB ,
567
+ connects .append (
568
+ mpatches .ConnectionPatch (
569
+ xyA , xyB ,
564
570
'axes fraction' , 'data' ,
565
571
axesA = inset_ax , axesB = self , arrowstyle = "-" ,
566
- zorder = zorder , edgecolor = edgecolor , alpha = alpha )]
572
+ zorder = zorder , edgecolor = edgecolor , alpha = alpha
573
+ )
574
+ )
567
575
self .add_patch (connects [- 1 ])
568
576
# decide which two of the lines to keep visible....
569
577
pos = inset_ax .get_position ()
@@ -579,7 +587,7 @@ def indicate_inset(self, bounds, inset_ax=None, *, transform=None,
579
587
connects [2 ].set_visible (x1 == y0 )
580
588
connects [3 ].set_visible (x1 ^ y1 )
581
589
582
- return rectpatch , connects
590
+ return rectpatch , tuple ( connects ) if connects else None
583
591
584
592
def indicate_inset_zoom (self , inset_ax , ** kwargs ):
585
593
"""
@@ -601,7 +609,7 @@ def indicate_inset_zoom(self, inset_ax, **kwargs):
601
609
chosen so as to not overlap with the indicator box.
602
610
603
611
**kwargs
604
- Other *kwargs* are passed on to `.Axes.inset_rectangle `
612
+ Other *kwargs* are passed on to `.Axes.indicate_inset `
605
613
606
614
Returns
607
615
-------
@@ -610,17 +618,21 @@ def indicate_inset_zoom(self, inset_ax, **kwargs):
610
618
Rectangle artist.
611
619
612
620
connector_lines : 4-tuple of `.Patches.ConnectionPatch`
613
- One for each of four connector lines. Two are set with visibility
614
- to *False*, but the user can set the visibility to True if the
615
- automatic choice is not deemed correct.
621
+ Each of four connector lines coming from the rectangle drawn on
622
+ this axis, in the order lower left, upper left, lower right,
623
+ upper right.
624
+ Two are set with visibility to *False*, but the user can
625
+ set the visibility to *True* if the automatic choice is not deemed
626
+ correct.
616
627
617
628
"""
618
629
619
630
xlim = inset_ax .get_xlim ()
620
631
ylim = inset_ax .get_ylim ()
621
- rect = [ xlim [0 ], ylim [0 ], xlim [1 ] - xlim [0 ], ylim [1 ] - ylim [0 ]]
632
+ rect = ( xlim [0 ], ylim [0 ], xlim [1 ] - xlim [0 ], ylim [1 ] - ylim [0 ])
622
633
rectpatch , connects = self .indicate_inset (
623
- rect , inset_ax , ** kwargs )
634
+ rect , inset_ax , ** kwargs
635
+ )
624
636
625
637
return rectpatch , connects
626
638
0 commit comments