@@ -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 rectangle 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,19 +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 : optional 4-tuple of `.Patches.ConnectionPatch`
8000
code>
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.
524
520
525
521
"""
526
-
527
522
# to make the axes connectors work, we need to apply the aspect to
528
523
# the parent axes.
529
524
self .apply_aspect ()
@@ -532,31 +527,36 @@ def indicate_inset(self, bounds, inset_ax=None, *, transform=None,
532
527
transform = self .transData
533
528
label = kwargs .pop ('label' , 'indicate_inset' )
534
529
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 )
540
536
541
537
connects = []
542
538
543
539
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
+
560
560
# decide which two of the lines to keep visible....
561
561
pos = inset_ax .get_position ()
562
562
bboxins = pos .transformed (self .figure .transFigure )
@@ -572,7 +572,7 @@ def indicate_inset(self, bounds, inset_ax=None, *, transform=None,
572
572
connects [2 ].set_visible (x1 == y0 )
573
573
connects [3 ].set_visible (x1 ^ y1 )
574
574
575
- return rectpatch , tuple (connects ) if connects else None
575
+ return rectangle_patch , tuple (connects ) if connects else None
576
576
577
577
def indicate_inset_zoom (self , inset_ax , ** kwargs ):
578
578
"""
0 commit comments