125
125
126
126
_P = ParamSpec ('_P' )
127
127
_R = TypeVar ('_R' )
128
+ _T = TypeVar ('_T' )
128
129
129
130
130
131
# We may not need the following imports here:
@@ -1602,8 +1603,56 @@ def subplots(
1602
1603
return fig , axs
1603
1604
1604
1605
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
+
1605
1654
def subplot_mosaic (
1606
- mosaic : str | HashableList ,
1655
+ mosaic : str | list [ HashableList [ _T ]] | list [ HashableList [ Hashable ]] ,
1607
1656
* ,
1608
1657
sharex : bool = False ,
1609
1658
sharey : bool = False ,
@@ -1612,9 +1661,13 @@ def subplot_mosaic(
1612
1661
empty_sentinel : Any = '.' ,
1613
1662
subplot_kw : dict [str , Any ] | None = None ,
1614
1663
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 ]]:
1618
1671
"""
1619
1672
Build a layout of Axes based on ASCII art or nested lists.
1620
1673
@@ -1716,12 +1769,13 @@ def subplot_mosaic(
1716
1769
1717
1770
"""
1718
1771
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 ,
1721
1775
height_ratios = height_ratios , width_ratios = width_ratios ,
1722
1776
subplot_kw = subplot_kw , gridspec_kw = gridspec_kw ,
1723
1777
empty_sentinel = empty_sentinel ,
1724
- per_subplot_kw = per_subplot_kw ,
1778
+ per_subplot_kw = per_subplot_kw , # type: ignore[arg-type]
1725
1779
)
1726
1780
return fig , ax_dict
1727
1781
0 commit comments