125125
126126 _P = ParamSpec ('_P' )
127127 _R = TypeVar ('_R' )
128+ _T = TypeVar ('_T' )
128129
129130
130131# We may not need the following imports here:
@@ -1602,8 +1603,56 @@ def subplots(
16021603 return fig , axs
16031604
16041605
1606+ @overload
1607+ def subplot_mosaic (
1608+ mosaic : str ,
1609+ * ,
1610+ sharex : bool = ...,
1611+ sharey : bool = ...,
1612+ width_ratios : ArrayLike | None = ...,
1613+ height_ratios : ArrayLike | None = ...,
1614+ empty_sentinel : str = ...,
1615+ subplot_kw : dict [str , Any ] | None = ...,
1616+ gridspec_kw : dict [str , Any ] | None = ...,
1617+ per_subplot_kw : dict [str | tuple [str , ...], dict [str , Any ]] | None = ...,
1618+ ** fig_kw : Any
1619+ ) -> tuple [Figure , dict [str , matplotlib .axes .Axes ]]: ...
1620+
1621+
1622+ @overload
1623+ def subplot_mosaic (
1624+ mosaic : list [HashableList [_T ]],
1625+ * ,
1626+ sharex : bool = ...,
1627+ sharey : bool = ...,
1628+ width_ratios : ArrayLike | None = ...,
1629+ height_ratios : ArrayLike | None = ...,
1630+ empty_sentinel : _T = ...,
1631+ subplot_kw : dict [str , Any ] | None = ...,
1632+ gridspec_kw : dict [str , Any ] | None = ...,
1633+ per_subplot_kw : dict [_T | tuple [_T , ...], dict [str , Any ]] | None = ...,
1634+ ** fig_kw : Any
1635+ ) -> tuple [Figure , dict [_T , matplotlib .axes .Axes ]]: ...
1636+
1637+
1638+ @overload
1639+ def subplot_mosaic (
1640+ mosaic : list [HashableList [Hashable ]],
1641+ * ,
1642+ sharex : bool = ...,
1643+ sharey : bool = ...,
1644+ width_ratios : ArrayLike | None = ...,
1645+ height_ratios : ArrayLike | None = ...,
1646+ empty_sentinel : Any = ...,
1647+ subplot_kw : dict [str , Any ] | None = ...,
1648+ gridspec_kw : dict [str , Any ] | None = ...,
1649+ per_subplot_kw : dict [Hashable | tuple [Hashable , ...], dict [str , Any ]] | None = ...,
1650+ ** fig_kw : Any
1651+ ) -> tuple [Figure , dict [Hashable , matplotlib .axes .Axes ]]: ...
1652+
1653+
16051654def subplot_mosaic (
1606- mosaic : str | HashableList ,
1655+ mosaic : str | list [ HashableList [ _T ]] | list [ HashableList [ Hashable ]] ,
16071656 * ,
16081657 sharex : bool = False ,
16091658 sharey : bool = False ,
@@ -1612,9 +1661,13 @@ def subplot_mosaic(
16121661 empty_sentinel : Any = '.' ,
16131662 subplot_kw : dict [str , Any ] | None = None ,
16141663 gridspec_kw : dict [str , Any ] | None = None ,
1615- per_subplot_kw : dict [Hashable , dict [str , Any ]] | None = None ,
1616- ** fig_kw
1617- ) -> tuple [Figure , dict [Hashable , matplotlib .axes .Axes ]]:
1664+ per_subplot_kw : dict [str | tuple [str , ...], dict [str , Any ]] |
1665+ dict [_T | tuple [_T , ...], dict [str , Any ]] |
1666+ dict [Hashable | tuple [Hashable , ...], dict [str , Any ]] | None = None ,
1667+ ** fig_kw : Any
1668+ ) -> tuple [Figure , dict [str , matplotlib .axes .Axes ]] | \
1669+ tuple [Figure , dict [_T , matplotlib .axes .Axes ]] | \
1670+ tuple [Figure , dict [Hashable , matplotlib .axes .Axes ]]:
16181671 """
16191672 Build a layout of Axes based on ASCII art or nested lists.
16201673
@@ -1716,12 +1769,13 @@ def subplot_mosaic(
17161769
17171770 """
17181771 fig = figure (** fig_kw )
1719- ax_dict = fig .subplot_mosaic (
1720- mosaic , sharex = sharex , sharey = sharey ,
1772+ ax_dict = fig .subplot_mosaic ( # type: ignore[misc]
1773+ mosaic , # type: ignore[arg-type]
1774+ sharex = sharex , sharey = sharey ,
17211775 height_ratios = height_ratios , width_ratios = width_ratios ,
17221776 subplot_kw = subplot_kw , gridspec_kw = gridspec_kw ,
17231777 empty_sentinel = empty_sentinel ,
1724- per_subplot_kw = per_subplot_kw ,
1778+ per_subplot_kw = per_subplot_kw , # type: ignore[arg-type]
17251779 )
17261780 return fig , ax_dict
17271781
0 commit comments