@@ -423,13 +423,12 @@ def inset_axes(self, bounds, *, transform=None, zorder=5,
423
423
parent axes.
424
424
425
425
**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.
428
427
429
428
Returns
430
429
-------
431
- Axes
432
- The created `.axes.Axes` instance.
430
+ ax
431
+ The created `~ .axes.Axes` instance.
433
432
434
433
Examples
435
434
--------
@@ -468,8 +467,7 @@ def indicate_inset(self, bounds, inset_ax=None, *, transform=None,
468
467
"""
469
468
Add an inset indicator to the axes. This is a rectangle on the plot
470
469
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`).
473
471
474
472
Warnings
475
473
--------
@@ -499,10 +497,10 @@ def indicate_inset(self, bounds, inset_ax=None, *, transform=None,
499
497
Color of the rectan
8000
gle and color of the connecting lines. Default
500
498
is '0.5'.
501
499
502
- alpha : number
500
+ alpha : float
503
501
Transparency of the rectangle and connector lines. Default is 0.5.
504
502
505
- zorder : number
503
+ zorder : float
506
504
Drawing order of the rectangle and connector lines. Default is 4.99
507
505
(just below the default level of inset axes).
508
506
@@ -511,16 +509,16 @@ def indicate_inset(self, bounds, inset_ax=None, *, transform=None,
511
509
512
510
Returns
513
511
-------
514
- rectangle_patch : `.Patches .Rectangle`
515
- Rectangle artist .
512
+ rectangle_patch : `.patches .Rectangle`
513
+ The indicator frame .
516
514
517
- connector_lines : 4-tuple of `.Patches.ConnectionPatch`
518
- One for each of four connector lines. Two are set with visibility
519
- to *False*, but the user can set the visibility to True if the
520
- 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.
521
520
522
521
"""
523
-
524
522
# to make the axes connectors work, we need to apply the aspect to
525
523
# the parent axes.
526
524
self .apply_aspect ()
@@ -529,26 +527,35 @@ def indicate_inset(self, bounds, inset_ax=None, *, transform=None,
529
527
transform = self .transData
530
528
label = kwargs .pop ('label' , 'indicate_inset' )
531
529
532
- xy = (bounds [0 ], bounds [1 ])
533
- rectpatch = mpatches .Rectangle (xy , bounds [2 ], bounds [3 ],
534
- facecolor = facecolor , edgecolor = edgecolor , alpha = alpha ,
535
- zorder = zorder , label = label , transform = transform , ** kwargs )
536
- 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 )
537
536
538
537
if inset_ax is not None :
539
- # want to connect the indicator to the rect....
538
+ # connect the inset_axes to the rectangle
540
539
connects = []
541
- xr = [bounds [0 ], bounds [0 ]+ bounds [2 ]]
542
- yr = [bounds [1 ], bounds [1 ]+ bounds [3 ]]
543
- for xc in range (2 ):
544
- for yc in range (2 ):
545
- xyA = (xc , yc )
546
- xyB = (xr [xc ], yr [yc ])
547
- connects += [mpatches .ConnectionPatch (xyA , xyB ,
548
- 'axes fraction' , 'data' ,
549
- axesA = inset_ax , axesB = self , arrowstyle = "-" ,
550
- zorder = zorder , edgecolor = edgecolor , alpha = alpha )]
551
- self .add_patch (connects [- 1 ])
540
+ for xy_inset_ax in [(0 , 0 ), (0 , 1 ), (1 , 0 ), (1 , 1 )]:
541
+ # inset_ax positions are in axes coordinates
542
+ # The 0, 1 values define the four edges if the inset_ax
543
+ # lower_left, upper_left, lower_right upper_right.
544
+ ex , ey = xy_inset_ax
545
+ if self .xaxis .get_inverted ():
546
+ ex = 1 - ex
547
+ if self .yaxis .get_inverted ():
548
+ ey = 1 - ey
549
+ xy_data = x + ex * width , y + ey * height
550
+ p = mpatches .ConnectionPatch (xy_inset_ax , xy_data ,
551
+ coordsA = 'axes fraction' ,
552
+ coordsB = 'data' ,
553
+ axesA = inset_ax , axesB = self ,
554
+ arrowstyle = "-" , zorder = zorder ,
555
+ edgecolor = edgecolor , alpha = alpha )
556
+ connects .append (p )
557
+ self .add_patch (p )
558
+
552
559
# decide which two of the lines to keep visible....
553
560
pos = inset_ax .get_position ()
554
561
bboxins = pos .transformed (self .figure .transFigure )
@@ -563,7 +570,7 @@ def indicate_inset(self, bounds, inset_ax=None, *, transform=None,
563
570
connects [2 ].set_visible (x1 == y0 )
564
571
connects [3 ].set_visible (x1 ^ y1 )
565
572
566
- return rectpatch , connects
573
+ return rectangle_patch , connects
567
574
568
575
def indicate_inset_zoom (self , inset_ax , ** kwargs ):
569
576
"""
0 commit comments