@@ -77,9 +77,10 @@ def _plot_args_replacer(args, data):
77
77
"supported due to ambiguity of arguments.\n Use "
78
78
"multiple plotting calls instead." )
79
79
80
+
80
81
def _make_inset_locator (rect , trans , parent ):
81
82
"""
82
- Helper function to locate inset axes, used in `.Axes.inset_axes `.
83
+ Helper function to locate inset axes, used in `.Axes.inset_axes_from_lbwh `.
83
84
84
85
A locator gets used in `Axes.set_aspect` to override the default
85
86
locations... It is a function that takes an axes object and
@@ -410,15 +411,20 @@ def legend(self, *args, **kwargs):
410
411
def _remove_legend (self , legend ):
411
412
self .legend_ = None
412
413
413
- def inset_axes_rect (self , rect , * , transform = None , zorder = 5 ,
414
+ def inset_axes_from_lbwh (self , lbwh , * , transform = None , zorder = 5 ,
414
415
** kwargs ):
415
416
"""
416
417
Add a child inset axes to this existing axes.
417
418
419
+ Warnings
420
+ --------
421
+
422
+ This method is experimental as of 3.0, and the API may change.
423
+
418
424
Parameters
419
425
----------
420
426
421
- rect : [x0, y0, width, height]
427
+ lbwh : [x0, y0, width, height]
422
428
Lower-left corner of inset axes, and its width and height.
423
429
424
430
transform : `.Transform`
@@ -430,15 +436,15 @@ def inset_axes_rect(self, rect, *, transform=None, zorder=5,
430
436
to change whether it is above or below data plotted on the
431
437
parent axes.
432
438
433
- Other Parameters
434
- ----------------
439
+ **kwargs
435
440
436
- Other *kwargs* are passed on to the `axes.Axes` child axes.
441
+ Other *kwargs* are passed on to the `axes.Axes` child axes.
437
442
F438
438
443
Returns
439
444
-------
440
445
441
- New `.axes.Axes` instance.
446
+ Axes
447
+ The created `.axes.Axes` instance.
442
448
443
449
Examples
444
450
--------
@@ -448,16 +454,17 @@ def inset_axes_rect(self, rect, *, transform=None, zorder=5,
448
454
449
455
fig, ax = plt.suplots()
450
456
ax.plot(range(10))
451
- axin1 = ax.inset_axes([0.8, 0.1, 0.15, 0.15])
452
- axin2 = ax.inset_axes([5, 7, 2.3, 2.3], transform=ax.transData)
457
+ axin1 = ax.inset_axes_from_lbwh([0.8, 0.1, 0.15, 0.15])
458
+ axin2 = ax.inset_axes_from_lbwh(
459
+ [5, 7, 2.3, 2.3], transform=ax.transData)
453
460
454
461
"""
455
462
if transform is None :
456
463
transform = self .transAxes
457
- label = kwargs .pop ('label' , 'inset_axes ' )
464
+ label = kwargs .pop ('label' , 'inset_axes_from_lbwh ' )
458
465
459
466
# This puts the rectangle into figure-relative coordinates.
460
- inset_locator = _make_inset_locator (rect , transform , self )
467
+ inset_locator = _make_inset_locator (lbwh , transform , self )
461
468
bb = inset_locator (None , None )
462
469
463
470
inset_ax = Axes (self .figure , bb .bounds , zorder = zorder ,
@@ -471,18 +478,24 @@ def inset_axes_rect(self, rect, *, transform=None, zorder=5,
471
478
472
479
return inset_ax
473
480
474
- def inset_indicator (self , rect , inset_ax = None , * , transform = None ,
481
+ def indicate_inset_lbwh (self , lbwh , inset_ax = None , * , transform = None ,
475
482
facecolor = 'none' , edgecolor = '0.5' , alpha = 0.5 ,
476
483
zorder = 4.99 , ** kwargs ):
477
484
"""
478
485
Add an inset indicator to the axes. This is a rectangle on the plot
479
- at the position indicated by *rect* that optionally has lines that
480
- connect the rectangle to an inset axes (`.Axes.inset_axes`).
486
+ at the position indicated by *lbwh* that optionally has lines that
487
+ connect the rectangle to an inset axes (`.Axes.inset_axes_from_lbwh`).
488
+
489
+ Warnings
490
+ --------
491
+
492
+ This method is experimental as of 3.0, and the API may change.
493
+
481
494
482
495
Parameters
483
496
----------
484
497
485
- rect : [x0, y0, width, height]
498
+ lbwh : [x0, y0, width, height]
486
499
Lower-left corner of rectangle to be marked, and its width
487
500
and height.
488
501
@@ -507,21 +520,21 @@ def inset_indicator(self, rect, inset_ax=None, *, transform=None,
507
520
Transparency of the rectangle and connector lines. Default is 0.5.
508
521
509
522
zorder : number
510
- drawing order of the rectangle and connector lines. Default is 4.99
523
+ Drawing order of the rectangle and connector lines. Default is 4.99
511
524
(just below the default level of inset axes).
512
525
513
- Other Parameters
514
- ----------------
515
-
516
- Other *kwargs* are passed on to the rectangle patch.
526
+ **kwargs
527
+ Other *kwargs* are passed on to the rectangle patch.
517
528
518
529
Returns
519
530
-------
520
531
521
- rectangle_patch, connector_lines :
522
- `.Patches.Rectangle`, (four-tuple `.Patches.ConnectionPatch`) one
523
- for each of four connector lines. Two are set with visibility to
524
- *False*, but the user can set the visibility to True if the
532
+ rectangle_patch: `.Patches.Rectangle`
533
+ Rectangle artist.
534
+
535
+ connector_lines: 4-tuple of `.Patches.ConnectionPatch`
536
+ One for each of four connector lines. Two are set with visibility
537
+ to *False*, but the user can set the visibility to True if the
525
538
automatic choice is not deemed correct.
526
539
527
540
"""
@@ -532,10 +545,10 @@ def inset_indicator(self, rect, inset_ax=None, *, transform=None,
532
545
533
546
if transform is None :
534
547
transform = self .transData
535
- label = kwargs .pop ('label' , 'inset_indicator ' )
548
+ label = kwargs .pop ('label' , 'indicate_inset_lbwh ' )
536
549
537
- xy = (rect [0 ], rect [1 ])
538
- rectpatch = mpatches .Rectangle (xy , rect [2 ], rect [3 ],
550
+ xy = (lbwh [0 ], lbwh [1 ])
551
+ rectpatch = mpatches .Rectangle (xy , lbwh [2 ], lbwh [3 ],
539
552
facecolor = facecolor , edgecolor = edgecolor , alpha = alpha ,
540
553
zorder = zorder , label = label , transform = transform , ** kwargs )
541
554
self .add_patch (rectpatch )
@@ -546,8 +559,8 @@ def inset_indicator(self, rect, inset_ax=None, *, transform=None,
546
559
pos = inset_ax .get_position () # this is in fig-fraction.
547
560
coordsA = 'axes fraction'
548
561
connects = []
549
- xr = [rect [0 ], rect [0 ]+ rect [2 ]]
550
- yr = [rect [1 ], rect [1 ]+ rect [3 ]]
562
+ xr = [lbwh [0 ], lbwh [0 ]+ lbwh [2 ]]
563
+ yr = [lbwh [1 ], lbwh [1 ]+ lbwh [3 ]]
551
564
for xc in range (2 ):
552
565
for yc in range (2 ):
553
566
xyA = (xc , yc )
@@ -561,7 +574,7 @@ def inset_indicator(self, rect, inset_ax=None, *, transform=None,
561
574
pos = inset_ax .get_position ()
562
575
bboxins = pos .transformed (self .figure .transFigure )
563
576
rectbbox = mtransforms .Bbox .from_bounds (
564
- * rect ).transformed (transform )
577
+ * lbwh ).transformed (transform )
565
578
if rectbbox .x0 < bboxins .x0 :
566
579
sig = 1
567
580
else :
@@ -575,12 +588,17 @@ def inset_indicator(self, rect, inset_ax=None, *, transform=None,
575
588
576
589
return rectpatch , connects
577
590
578
- def zoom_inset_indicator (self , inset_ax , ** kwargs ):
591
+ def indicate_inset_zoom (self , inset_ax , ** kwargs ):
579
592
"""
580
593
Add an inset indicator rectangle to the axes based on the axis
581
594
limits for an *inset_ax* and draw connectors between *inset_ax*
582
595
and the rectangle.
583
596
597
+ Warnings
598
+ --------
599
+
600
+ This method is experimental as of 3.0, and the API may change.
601
+
584
602
Parameters
585
603
----------
586
604
@@ -589,26 +607,27 @@ def zoom_inset_indicator(self, inset_ax, **kwargs):
589
607
drawn connecting the indicator box to the inset axes on corners
590
608
chosen so as to not overlap with the indicator box.
591
609
592
- Other Parameters
593
- ----------------
594
-
595
- Other *kwargs* are passed on to `.Axes.inset_rectangle`
610
+ **kwargs
611
+ Other *kwargs* are passed on to `.Axes.inset_rectangle`
596
612
597
613
Returns
598
614
-------
599
615
600
- rectangle_patch, connector_lines :
601
- `.Patches.Rectangle`, (four-tuple `.Patches.ConnectionPatch`) one
602
- for each of four connector lines. Two are set with visibility to
603
- *False*, but the user can set the visibility to True if the
616
+ rectangle_patch: `.Patches.Rectangle`
617
+ Rectangle artist.
618
+
619
+ connector_lines: 4-tuple of `.Patches.ConnectionPatch`
620
+ One for each of four connector lines. Two are set with visibility
621
+ to *False*, but the user can set the visibility to True if the
604
622
automatic choice is not deemed correct.
605
623
606
624
"""
607
625
608
626
xlim = inset_ax .get_xlim ()
609
627
ylim = inset_ax .get_ylim ()
610
628
rect = [xlim [0 ], ylim [0 ], xlim [1 ] - xlim [0 ], ylim [1 ] - ylim [0 ]]
611
- rectpatch , connects = self .inset_indicator (rect , inset_ax , ** kwargs )
629
+ rectpatch , connects = self .indicate_inset_lbwh (
630
+ rect , inset_ax , ** kwargs )
612
631
613
632
return rectpatch , connects
614
633
0 commit comments