@@ -529,9 +529,16 @@ def _maybe_right_yaxis(self, ax: Axes, axes_num: int) -> Axes:
529
529
# otherwise, create twin axes
530
530
orig_ax , new_ax = ax , ax .twinx ()
531
531
# TODO: use Matplotlib public API when available
532
- new_ax ._get_lines = orig_ax ._get_lines
533
- new_ax ._get_patches_for_fill = orig_ax ._get_patches_for_fill
534
- orig_ax .right_ax , new_ax .left_ax = new_ax , orig_ax
532
+ new_ax ._get_lines = orig_ax ._get_lines # type: ignore[attr-defined]
533
+ # TODO #54485
534
+ new_ax ._get_patches_for_fill = ( # type: ignore[attr-defined]
535
+ orig_ax ._get_patches_for_fill # type: ignore[attr-defined]
536
+ )
537
+ # TODO #54485
538
+ orig_ax .right_ax , new_ax .left_ax = ( # type: ignore[attr-defined]
539
+ new_ax ,
540
+ orig_ax ,
541
+ )
535
542
536
543
if not self ._has_plotted_object (orig_ax ): # no data on left y
537
544
orig_ax .get_yaxis ().set_visible (False )
@@ -540,7 +547,7 @@ def _maybe_right_yaxis(self, ax: Axes, axes_num: int) -> Axes:
540
547
new_ax .set_yscale ("log" )
541
548
elif self .logy == "sym" or self .loglog == "sym" :
542
549
new_ax .set_yscale ("symlog" )
543
- return new_ax
550
+ return new_ax # type: ignore[return-value]
544
551
545
552
@final
546
553
@cache_readonly
@@ -1206,12 +1213,15 @@ def _get_errorbars(
1206
1213
1207
1214
@final
1208
1215
def _get_subplots (self , fig : Figure ):
1209
- from matplotlib .axes import Subplot
1216
+ if Version (mpl .__version__ ) < Version ("3.8" ):
1217
+ from matplotlib .axes import Subplot as Klass
1218
+ else :
1219
+ from matplotlib .axes import Axes as Klass
1210
1220
1211
1221
return [
1212
1222
ax
1213
1223
for ax in fig .get_axes ()
1214
- if (isinstance (ax , Subplot ) and ax .get_subplotspec () is not None )
1224
+ if (isinstance (ax , Klass ) and ax .get_subplotspec () is not None )
1215
1225
]
1216
1226
1217
1227
@final
@@ -1255,8 +1265,10 @@ def _post_plot_logic(self, ax: Axes, data) -> None:
1255
1265
x , y = self .x , self .y
1256
1266
xlabel = self .xlabel if self .xlabel is not None else pprint_thing (x )
1257
1267
ylabel = self .ylabel if self .ylabel is not None else pprint_thing (y )
1258
- ax .set_xlabel (xlabel )
1259
- ax .set_ylabel (ylabel )
1268
+ # error: Argument 1 to "set_xlabel" of "_AxesBase" has incompatible
1269
+ # type "Hashable"; expected "str"
1270
+ ax .set_xlabel (xlabel ) # type: ignore[arg-type]
1271
+ ax .set_ylabel (ylabel ) # type: ignore[arg-type]
1260
1272
1261
1273
@final
1262
1274
def _plot_colorbar (self , ax : Axes , * , fig : Figure , ** kwds ):
@@ -1393,7 +1405,7 @@ def _get_norm_and_cmap(self, c_values, color_by_categorical: bool):
1393
1405
else :
1394
1406
cmap = None
1395
1407
1396
- if color_by_categorical :
1408
+ if color_by_categorical and cmap is not None :
1397
1409
from matplotlib import colors
1398
1410
1399
1411
n_cats = len (self .data [c ].cat .categories )
@@ -1584,13 +1596,13 @@ def _ts_plot(self, ax: Axes, x, data: Series, style=None, **kwds):
1584
1596
decorate_axes (ax .left_ax , freq , kwds )
1585
1597
if hasattr (ax , "right_ax" ):
1586
1598
decorate_axes (ax .right_ax , freq , kwds )
1587
- ax ._plot_data .append ((data , self ._kind , kwds ))
1599
+ # TODO #54485
1600
+ ax ._plot_data .append ((data , self ._kind , kwds )) # type: ignore[attr-defined]
1588
1601
1589
1602
lines = self ._plot (ax , data .index , np .asarray (data .values ), style = style , ** kwds )
1590
1603
# set date formatter, locators and rescale limits
1591
- # error: Argument 3 to "format_dateaxis" has incompatible type "Index";
1592
- # expected "DatetimeIndex | PeriodIndex"
1593
- format_dateaxis (ax , ax .freq , data .index ) # type: ignore[arg-type]
1604
+ # TODO #54485
1605
+ format_dateaxis (ax , ax .freq , data .index ) # type: ignore[arg-type, attr-defined]
1594
1606
return lines
1595
1607
1596
1608
@final
@@ -1606,11 +1618,15 @@ def _initialize_stacker(cls, ax: Axes, stacking_id, n: int) -> None:
1606
1618
if stacking_id is None :
1607
1619
return
1608
1620
if not hasattr (ax , "_stacker_pos_prior" ):
1609
- ax ._stacker_pos_prior = {}
1621
+ # TODO #54485
1622
+ ax ._stacker_pos_prior = {} # type: ignore[attr-defined]
1610
1623
if not hasattr (ax , "_stacker_neg_prior" ):
1611
- ax ._stacker_neg_prior = {}
1612
- ax ._stacker_pos_prior [stacking_id ] = np .zeros (n )
1613
- ax ._stacker_neg_prior [stacking_id ] = np .zeros (n )
1624
+ # TODO #54485
1625
+ ax ._stacker_neg_prior = {} # type: ignore[attr-defined]
1626
+ # TODO #54485
1627
+ ax ._stacker_pos_prior [stacking_id ] = np .zeros (n ) # type: ignore[attr-defined]
1628
+ # TODO #54485
1629
+ ax ._stacker_neg_prior [stacking_id ] = np .zeros (n ) # type: ignore[attr-defined]
1614
1630
1615
1631
@final
1616
1632
@classmethod
@@ -1624,9 +1640,17 @@ def _get_stacked_values(
1624
1640
cls ._initialize_stacker (ax , stacking_id , len (values ))
1625
1641
1626
1642
if (values >= 0 ).all ():
1627
- return ax ._stacker_pos_prior [stacking_id ] + values
1643
+ # TODO #54485
1644
+ return (
1645
+ ax ._stacker_pos_prior [stacking_id ] # type: ignore[attr-defined]
1646
+ + values
1647
+ )
1628
1648
elif (values <= 0 ).all ():
1629
- return ax ._stacker_neg_prior [stacking_id ] + values
1649
+ # TODO #54485
1650
+ return (
1651
+ ax ._stacker_neg_prior [stacking_id ] # type: ignore[attr-defined]
1652
+ + values
1653
+ )
1630
1654
1631
1655
raise ValueError (
1632
1656
"When stacked is True, each column must be either "
@@ -1640,9 +1664,11 @@ def _update_stacker(cls, ax: Axes, stacking_id: int | None, values) -> None:
1640
1664
if stacking_id is None :
1641
1665
return
1642
1666
if (values >= 0 ).all ():
1643
- ax ._stacker_pos_prior [stacking_id ] += values
1667
+ # TODO #54485
1668
+ ax ._stacker_pos_prior [stacking_id ] += values # type: ignore[attr-defined]
1644
1669
elif (values <= 0 ).all ():
1645
- ax ._stacker_neg_prior [stacking_id ] += values
1670
+ # TODO #54485
1671
+ ax ._stacker_neg_prior [stacking_id ] += values # type: ignore[attr-defined]
1646
1672
1647
1673
def _post_plot_logic (self , ax : Axes , data ) -> None :
1648
1674
from matplotlib .ticker import FixedLocator
@@ -1658,7 +1684,9 @@ def get_label(i):
1658
1684
if self ._need_to_set_index :
1659
1685
xticks = ax .get_xticks ()
1660
1686
xticklabels = [get_label (x ) for x in xticks ]
1661
- ax .xaxis .set_major_locator (FixedLocator (xticks ))
1687
+ # error: Argument 1 to "FixedLocator" has incompatible type "ndarray[Any,
1688
+ # Any]"; expected "Sequence[float]"
1689
+ ax .xaxis .set_major_locator (FixedLocator (xticks )) # type: ignore[arg-type]
1662
1690
ax .set_xticklabels (xticklabels )
1663
1691
1664
1692
# If the index is an irregular time series, then by default
@@ -1737,9 +1765,11 @@ def _plot( # type: ignore[override]
1737
1765
if stacking_id is None :
1738
1766
start = np .zeros (len (y ))
1739
1767
elif (y >= 0 ).all ():
1740
- start = ax ._stacker_pos_prior [stacking_id ]
1768
+ # TODO #54485
1769
+ start = ax ._stacker_pos_prior [stacking_id ] # type: ignore[attr-defined]
1741
1770
elif (y <= 0 ).all ():
1742
- start = ax ._stacker_neg_prior [stacking_id ]
1771
+ # TODO #54485
1772
+ start = ax ._stacker_neg_prior [stacking_id ] # type: ignore[attr-defined]
1743
1773
else :
1744
1774
start = np .zeros (len (y ))
1745
1775
@@ -2005,7 +2035,9 @@ def _decorate_ticks(
2005
2035
ax .set_yticklabels (ticklabels )
2006
2036
if name is not None and self .use_index :
2007
2037
ax .set_ylabel (name )
2008
- ax .set_xlabel (self .xlabel )
2038
+ # error: Argument 1 to "set_xlabel" of "_AxesBase" has incompatible type
2039
+ # "Hashable | None"; expected "str"
2040
+ ax .set_xlabel (self .xlabel ) # type: ignore[arg-type]
2009
2041
2010
2042
2011
2043
class PiePlot (MPLPlot ):
0 commit comments