@@ -423,13 +423,12 @@ def inset_axes(self, bounds, *, transform=None, zorder=5,
423423 parent axes.
424424
425425 **kwargs
426-
427- Other *kwargs* are passed on to the `axes.Axes` child axes.
426+ Other *kwargs* are passed on to the `~.axes.Axes` child axes.
428427
429428 Returns
430429 -------
431- Axes
432- The created `.axes.Axes` instance.
430+ ax
431+ The created `~ .axes.Axes` instance.
433432
434433 Examples
435434 --------
@@ -468,8 +467,7 @@ def indicate_inset(self, bounds, inset_ax=None, *, transform=None,
468467 """
469468 Add an inset indicator to the axes. This is a rectangle on the plot
470469 at the position indicated by *bounds* that optionally has lines that
471- connect the rectangle to an inset axes
472- (`.Axes.inset_axes`).
470+ connect the rectangle to an inset axes (`.Axes.inset_axes`).
473471
474472 Warnings
475473 --------
@@ -499,10 +497,10 @@ def indicate_inset(self, bounds, inset_ax=None, *, transform=None,
499497 Color of the rectangle and color of the connecting lines. Default
500498 is '0.5'.
501499
502- alpha : number
500+ alpha : float
503501 Transparency of the rectangle and connector lines. Default is 0.5.
504502
505- zorder : number
503+ zorder : float
506504 Drawing order of the rectangle and connector lines. Default is 4.99
507505 (just below the default level of inset axes).
508506
@@ -511,19 +509,16 @@ def indicate_inset(self, bounds, inset_ax=None, *, transform=None,
511509
512510 Returns
513511 -------
514- rectangle_patch : `.Patches .Rectangle`
515- Rectangle artist .
512+ rectangle_patch : `.patches .Rectangle`
513+ The indicator frame .
516514
517- connector_lines : optional 4-tuple of `.Patches.ConnectionPatch`
518- Each of four connector lines coming from the given rectangle
519- on this axes in the order lower left, upper left, lower right,
520- upper right: *None* if *inset_ax* is *None*.
521- Two are set with visibility to *False*,
522- but the user can set the visibility to *True* if the
523- automatic choice is not deemed correct.
515+ connector_lines : 4-tuple of `.patches.ConnectionPatch`
516+ The four connector lines connecting to (lower_left, upper_left,
517+ lower_right upper_right) corners of *inset_ax*. Two lines are
518+ set with visibility to *False*, but the user can set the
519+ visibility to True if the automatic choice is not deemed correct.
524520
525521 """
526-
527522 # to make the axes connectors work, we need to apply the aspect to
528523 # the parent axes.
529524 self .apply_aspect ()
@@ -532,31 +527,36 @@ def indicate_inset(self, bounds, inset_ax=None, *, transform=None,
532527 transform = self .transData
533528 label = kwargs .pop ('label' , 'indicate_inset' )
534529
535- xy = (bounds [0 ], bounds [1 ])
536- rectpatch = mpatches .Rectangle (xy , bounds [2 ], bounds [3 ],
537- facecolor = facecolor , edgecolor = edgecolor , alpha = alpha ,
538- zorder = zorder , label = label , transform = transform , ** kwargs )
539- self .add_patch (rectpatch )
530+ x , y , width , height = bounds
531+ rectangle_patch = mpatches .Rectangle (
532+ (x , y ), width , height ,
533+ facecolor = facecolor , edgecolor = edgecolor , alpha = alpha ,
534+ zorder = zorder , label = label , transform = transform , ** kwargs )
535+ self .add_patch (rectangle_patch )
540536
541537 connects = []
542538
543539 if inset_ax is not None :
544- # want to connect the indicator to the rect....
545- xr = [bounds [0 ], bounds [0 ]+ bounds [2 ]]
546- yr = [bounds [1 ], bounds [1 ]+ bounds [3 ]]
547- for xc in range (2 ):
548- for yc in range (2 ):
549- xyA = (xc , yc )
550- xyB = (xr [xc ], yr [yc ])
551- connects .append (
552- mpatches .ConnectionPatch (
553- xyA , xyB ,
554- 'axes fraction' , 'data' ,
555- axesA = inset_ax , axesB = self , arrowstyle = "-" ,
556- zorder = zorder , edgecolor = edgecolor , alpha = alpha
557- )
558- )
559- self .add_patch (connects [- 1 ])
540+ # connect the inset_axes to the rectangle
541+ for xy_inset_ax in [(0 , 0 ), (0 , 1 ), (1 , 0 ), (1 , 1 )]:
542+ # inset_ax positions are in axes coordinates
543+ # The 0, 1 values define the four edges if the inset_ax
544+ # lower_left, upper_left, lower_right upper_right.
545+ ex , ey = xy_inset_ax
546+ if self .xaxis .get_inverted ():
547+ ex = 1 - ex
548+ if self .yaxis .get_inverted ():
549+ ey = 1 - ey
550+ xy_data = x + ex * width , y + ey * height
551+ p = mpatches .ConnectionPatch (xy_inset_ax , xy_data ,
552+ coordsA = 'axes fraction' ,
553+ coordsB = 'data' ,
554+ axesA = inset_ax , axesB = self ,
555+ arrowstyle = "-" , zorder = zorder ,
556+ edgecolor = edgecolor , alpha = alpha )
557+ connects .append (p )
558+ self .add_patch (p )
559+
560560 # decide which two of the lines to keep visible....
561561 pos = inset_ax .get_position ()
562562 bboxins = pos .transformed (self .figure .transFigure )
@@ -572,7 +572,7 @@ def indicate_inset(self, bounds, inset_ax=None, *, transform=None,
572572 connects [2 ].set_visible (x1 == y0 )
573573 connects [3 ].set_visible (x1 ^ y1 )
574574
575- return rectpatch , tuple (connects ) if connects else None
575+ return rectangle_patch , tuple (connects ) if connects else None
576576
577577 def indicate_inset_zoom (self , inset_ax , ** kwargs ):
578578 """
0 commit comments