2424from pandas .tseries .frequencies import get_period_alias , is_subperiod , is_superperiod
2525
2626if TYPE_CHECKING :
27- from pandas import Index , Series # noqa:F401
27+ from matplotlib . axes import Axes
2828
29+ from pandas import Index , Series # noqa:F401
2930
3031# ---------------------------------------------------------------------
3132# Plotting functions and monkey patches
3233
3334
34- def _maybe_resample (series : "Series" , ax , kwargs ):
35+ def _maybe_resample (series : "Series" , ax : "Axes" , kwargs ):
3536 # resample against axes freq if necessary
3637 freq , ax_freq = _get_freq (ax , series )
3738
@@ -74,7 +75,7 @@ def _is_sup(f1: str, f2: str) -> bool:
7475 )
7576
7677
77- def _upsample_others (ax , freq , kwargs ):
78+ def _upsample_others (ax : "Axes" , freq , kwargs ):
7879 legend = ax .get_legend ()
7980 lines , labels = _replot_ax (ax , freq , kwargs )
8081 _replot_ax (ax , freq , kwargs )
@@ -97,7 +98,7 @@ def _upsample_others(ax, freq, kwargs):
9798 ax .legend (lines , labels , loc = "best" , title = title )
9899
99100
100- def _replot_ax (ax , freq , kwargs ):
101+ def _replot_ax (ax : "Axes" , freq , kwargs ):
101102 data = getattr (ax , "_plot_data" , None )
102103
103104 # clear current axes and data
@@ -127,7 +128,7 @@ def _replot_ax(ax, freq, kwargs):
127128 return lines , labels
128129
129130
130- def _decorate_axes (ax , freq , kwargs ):
131+ def _decorate_axes (ax : "Axes" , freq , kwargs ):
131132 """Initialize axes for time-series plotting"""
132133 if not hasattr (ax , "_plot_data" ):
133134 ax ._plot_data = []
@@ -143,7 +144,7 @@ def _decorate_axes(ax, freq, kwargs):
143144 ax .date_axis_info = None
144145
145146
146- def _get_ax_freq (ax ):
147+ def _get_ax_freq (ax : "Axes" ):
147148 """
148149 Get the freq attribute of the ax object if set.
149150 Also checks shared axes (eg when using secondary yaxis, sharex=True
@@ -174,7 +175,7 @@ def _get_period_alias(freq) -> Optional[str]:
174175 return freq
175176
176177
177- def _get_freq (ax , series : "Series" ):
178+ def _get_freq (ax : "Axes" , series : "Series" ):
178179 # get frequency from data
179180 freq = getattr (series .index , "freq" , None )
180181 if freq is None :
@@ -192,7 +193,7 @@ def _get_freq(ax, series: "Series"):
192193 return freq , ax_freq
193194
194195
195- def _use_dynamic_x (ax , data : " FrameOrSeriesUnion" ) -> bool :
196+ def _use_dynamic_x (ax : "Axes" , data : FrameOrSeriesUnion ) -> bool :
196197 freq = _get_index_freq (data .index )
197198 ax_freq = _get_ax_freq (ax )
198199
@@ -234,7 +235,7 @@ def _get_index_freq(index: "Index") -> Optional[BaseOffset]:
234235 return freq
235236
236237
237- def _maybe_convert_index (ax , data ):
238+ def _maybe_convert_index (ax : "Axes" , data ):
238239 # tsplot converts automatically, but don't want to convert index
239240 # over and over for DataFrames
240241 if isinstance (data .index , (ABCDatetimeIndex , ABCPeriodIndex )):
@@ -264,7 +265,7 @@ def _maybe_convert_index(ax, data):
264265# Do we need the rest for convenience?
265266
266267
267- def _format_coord (freq , t , y ):
268+ def _format_coord (freq , t , y ) -> str :
268269 time_period = Period (ordinal = int (t ), freq = freq )
269270 return f"t = { time_period } y = { y :8f} "
270271
0 commit comments