@@ -1189,6 +1189,8 @@ def sca(ax: Axes) -> None:
11891189 Set the current Axes to *ax* and the current Figure to the parent of *ax*.
11901190 """
11911191 figure (ax .figure )
1192+ # Mypy sees ax.figure as potentially None,
1193+ # but if you are calling this, it won't be None
11921194 ax .figure .sca (ax ) # type: ignore
11931195
11941196
@@ -1201,7 +1203,7 @@ def cla() -> None:
12011203## More ways of creating axes ##
12021204
12031205@_docstring .dedent_interpd
1204- def subplot (* args , ** kwargs ) -> matplotlib . axes . Axes :
1206+ def subplot (* args , ** kwargs ) -> Axes :
12051207 """
12061208 Add an Axes to the current figure or retrieve an existing Axes.
12071209
@@ -1411,7 +1413,7 @@ def subplots(
14111413 subplot_kw : dict [str , Any ] | None = None ,
14121414 gridspec_kw : dict [str , Any ] | None = None ,
14131415 ** fig_kw
1414- ) -> tuple [Figure , matplotlib . axes . Axes | np .ndarray | SubplotBase ]:
1416+ ) -> tuple [Figure , Axes | np .ndarray | SubplotBase ]:
14151417 """
14161418 Create a figure and a set of subplots.
14171419
@@ -1575,7 +1577,7 @@ def subplot_mosaic(
15751577 gridspec_kw : dict [str , Any ] | None = None ,
15761578 per_subplot_kw : dict [Any , dict [str , Any ]] | None = None ,
15771579 ** fig_kw
1578- ) -> tuple [Figure , dict [Any , matplotlib . axes . Axes ]]:
1580+ ) -> tuple [Figure , dict [Any , Axes ]]:
15791581 """
15801582 Build a layout of Axes based on ASCII art or nested lists.
15811583
@@ -1754,7 +1756,7 @@ def subplot2grid(
17541756 return ax
17551757
17561758
1757- def twinx (ax : matplotlib . axes . Axes | None = None ) -> _AxesBase :
1759+ def twinx (ax : Axes | None = None ) -> _AxesBase :
17581760 """
17591761 Make and return a second axes that shares the *x*-axis. The new axes will
17601762 overlay *ax* (or the current axes if *ax* is *None*), and its ticks will be
@@ -1770,7 +1772,7 @@ def twinx(ax: matplotlib.axes.Axes | None = None) -> _AxesBase:
17701772 return ax1
17711773
17721774
1773- def twiny (ax : matplotlib . axes . Axes | None = None ) -> _AxesBase :
1775+ def twiny (ax : Axes | None = None ) -> _AxesBase :
17741776 """
17751777 Make and return a second axes that shares the *y*-axis. The new axes will
17761778 overlay *ax* (or the current axes if *ax* is *None*), and its ticks will be
@@ -2225,8 +2227,8 @@ def _get_pyplot_commands() -> list[str]:
22252227@_copy_docstring_and_deprecators (Figure .colorbar )
22262228def colorbar (
22272229 mappable : ScalarMappable | None = None ,
2228- cax : matplotlib . axes . Axes | None = None ,
2229- ax : matplotlib . axes . Axes | Iterable [matplotlib . axes . Axes ] | None = None ,
2230+ cax : Axes | None = None ,
2231+ ax : Axes | Iterable [Axes ] | None = None ,
22302232 ** kwargs
22312233) -> Colorbar :
22322234 if mappable is None :
0 commit comments