4
4
import logging
5
5
import math
6
6
from numbers import Number
7
+ from typing import Tuple , Optional
7
8
8
- import numpy as np
9
- from numpy import ma
10
-
11
- from matplotlib import _preprocess_data , rcParams
9
+ import matplotlib .category as _ # <-registers a category unit converter
12
10
import matplotlib .cbook as cbook
13
11
import matplotlib .collections as mcoll
14
12
import matplotlib .colors as mcolors
15
13
import matplotlib .contour as mcontour
16
- import matplotlib .category as _ # <-registers a category unit converter
17
14
import matplotlib .dates as _ # <-registers a date unit converter
18
15
import matplotlib .docstring as docstring
19
16
import matplotlib .image as mimage
20
17
import matplotlib .legend as mlegend
21
18
import matplotlib .lines as mlines
22
19
import matplotlib .markers as mmarkers
23
20
import matplotlib .mlab as mlab
24
- import matplotlib .path as mpath
25
21
import matplotlib .patches as mpatches
22
+ import matplotlib .path as mpath
26
23
import matplotlib .quiver as mquiver
27
24
import matplotlib .stackplot as mstack
28
25
import matplotlib .streamplot as mstream
31
28
import matplotlib .ticker as mticker
32
29
import matplotlib .transforms as mtransforms
33
30
import matplotlib .tri as mtri
34
- from matplotlib .container import BarContainer , ErrorbarContainer , StemContainer
31
+ import numpy as np
32
+ from matplotlib import _preprocess_data , rcParams
35
33
from matplotlib .axes ._base import _AxesBase , _process_plot_format
36
34
from matplotlib .axes ._secondary_axes import SecondaryAxis
35
+ from matplotlib .container import BarContainer , ErrorbarContainer , StemContainer
36
+ from numpy import ma
37
37
38
38
try :
39
39
from numpy .lib .histograms import histogram_bin_edges
@@ -408,8 +408,14 @@ def legend(self, *args, **kwargs):
408
408
def _remove_legend (self , legend ):
409
409
self .legend_ = None
410
410
411
- def inset_axes (self , bounds , * , transform = None , zorder = 5 ,
412
- ** kwargs ):
411
+ def inset_axes (
412
+ self ,
413
+ bounds : Tuple [float , float , float , float ],
414
+ * ,
415
+ transform : Optional [mtransforms .Transform ] = None ,
416
+ zorder : float = 5 ,
417
+ ** kwargs
418
+ ):
413
419
"""
414
420
Add a child inset axes to this existing axes.
415
421
@@ -475,9 +481,25 @@ def inset_axes(self, bounds, *, transform=None, zorder=5,
475
481
476
482
return inset_ax
477
483
478
- def indicate_inset (self , bounds , inset_ax = None , * , transform = None ,
479
- facecolor = 'none' , edgecolor = '0.5' , alpha = 0.5 ,
480
- zorder = 4.99 , ** kwargs ):
484
+ def indicate_inset (
485
+ self ,
486
+ bounds : Tuple [float , float , float , float ],
487
+ inset_ax : Optional ['Axes' ] = None ,
488
+ * ,
489
+ transform : Optional [mtransforms .Transform ] = None ,
490
+ facecolor = 'none' ,
491
+ edgecolor = '0.5' ,
492
+ alpha : float = 0.5 ,
493
+ zorder : float = 4.99 , ** kwargs
494
+ ) -> Tuple [
495
+ mpatches .Rectangle ,
496
+ Optional [
497
+ Tuple [
498
+ mpatches .ConnectionPatch , mpatches .ConnectionPatch ,
499
+ mpatches .ConnectionPatch , mpatches .ConnectionPatch
500
+ ]
501
+ ]
502
+ ]:
481
503
"""
482
504
Add an inset indicator to the axes. This is a rectangle on the plot
483
505
at the position indicated by *bounds* that optionally has lines that
@@ -577,7 +599,8 @@ def indicate_inset(self, bounds, inset_ax=None, *, transform=None,
577
599
pos = inset_ax .get_position ()
578
600
bboxins = pos .transformed (self .figure .transFigure )
579
601
rectbbox = mtransforms .Bbox .from_bounds (
580
- * bounds ).transformed (transform )
602
+ * bounds
603
+ ).transformed (transform )
581
604
x0 = rectbbox .x0 < bboxins .x0
582
605
x1 = rectbbox .x1 < bboxins .x1
583
606
y0 = rectbbox .y0 < bboxins .y0
@@ -589,7 +612,15 @@ def indicate_inset(self, bounds, inset_ax=None, *, transform=None,
589
612
590
613
return rectpatch , tuple (connects ) if connects else None
591
614
592
- def indicate_inset_zoom (self , inset_ax , ** kwargs ):
615
+ def indicate_inset_zoom (
616
+ self , inset_ax : 'Axes' , ** kwargs
617
+ ) -> Tuple [
618
+ mpatches .Rectangle ,
619
+ Tuple [
620
+ mpatches .ConnectionPatch , mpatches .ConnectionPatch ,
621
+ mpatches .ConnectionPatch , mpatches .ConnectionPatch
622
+ ]
623
+ ]:
593
624
"""
594
625
Add an inset indicator rectangle to the axes based on the axis
595
626
limits for an *inset_ax* and draw connectors between *inset_ax*
0 commit comments