@@ -1215,6 +1215,8 @@ def sca(ax: Axes) -> None:
12151215 Set the current Axes to *ax* and the current Figure to the parent of *ax*.
12161216 """
12171217 figure (ax .figure )
1218+ # Mypy sees ax.figure as potentially None,
1219+ # but if you are calling this, it won't be None
12181220 ax .figure .sca (ax ) # type: ignore
12191221
12201222
@@ -1227,7 +1229,7 @@ def cla() -> None:
12271229## More ways of creating axes ##
12281230
12291231@_docstring .dedent_interpd
1230- def subplot (* args , ** kwargs ) -> matplotlib . axes . Axes :
1232+ def subplot (* args , ** kwargs ) -> Axes :
12311233 """
12321234 Add an Axes to the current figure or retrieve an existing Axes.
12331235
@@ -1437,7 +1439,7 @@ def subplots(
14371439 subplot_kw : dict [str , Any ] | None = None ,
14381440 gridspec_kw : dict [str , Any ] | None = None ,
14391441 ** fig_kw
1440- ) -> tuple [Figure , matplotlib . axes . Axes | np .ndarray | SubplotBase ]:
1442+ ) -> tuple [Figure , Axes | np .ndarray | SubplotBase ]:
14411443 """
14421444 Create a figure and a set of subplots.
14431445
@@ -1601,7 +1603,7 @@ def subplot_mosaic(
16011603 gridspec_kw : dict [str , Any ] | None = None ,
16021604 per_subplot_kw : dict [Any , dict [str , Any ]] | None = None ,
16031605 ** fig_kw
1604- ) -> tuple [Figure , dict [Any , matplotlib . axes . Axes ]]:
1606+ ) -> tuple [Figure , dict [Any , Axes ]]:
16051607 """
16061608 Build a layout of Axes based on ASCII art or nested lists.
16071609
@@ -1780,7 +1782,7 @@ def subplot2grid(
17801782 return ax
17811783
17821784
1783- def twinx (ax : matplotlib . axes . Axes | None = None ) -> _AxesBase :
1785+ def twinx (ax : Axes | None = None ) -> _AxesBase :
17841786 """
17851787 Make and return a second axes that shares the *x*-axis. The new axes will
17861788 overlay *ax* (or the current axes if *ax* is *None*), and its ticks will be
@@ -1796,7 +1798,7 @@ def twinx(ax: matplotlib.axes.Axes | None = None) -> _AxesBase:
17961798 return ax1
17971799
17981800
1799- def twiny (ax : matplotlib . axes . Axes | None = None ) -> _AxesBase :
1801+ def twiny (ax : Axes | None = None ) -> _AxesBase :
18001802 """
18011803 Make and return a second axes that shares the *y*-axis. The new axes will
18021804 overlay *ax* (or the current axes if *ax* is *None*), and its ticks will be
@@ -2251,8 +2253,8 @@ def _get_pyplot_commands() -> list[str]:
22512253@_copy_docstring_and_deprecators (Figure .colorbar )
22522254def colorbar (
22532255 mappable : ScalarMappable | None = None ,
2254- cax : matplotlib . axes . Axes | None = None ,
2255- ax : matplotlib . axes . Axes | Iterable [matplotlib . axes . Axes ] | None = None ,
2256+ cax : Axes | None = None ,
2257+ ax : Axes | Iterable [Axes ] | None = None ,
22562258 ** kwargs
22572259) -> Colorbar :
22582260 if mappable is None :
0 commit comments