diff --git a/pandas/plotting/_matplotlib/converter.py b/pandas/plotting/_matplotlib/converter.py index 848fb77c942fb..0eb3318ac96c5 100644 --- a/pandas/plotting/_matplotlib/converter.py +++ b/pandas/plotting/_matplotlib/converter.py @@ -983,10 +983,7 @@ def __init__( def _get_default_locs(self, vmin, vmax): """Returns the default locations of ticks.""" - if self.plot_obj.date_axis_info is None: - self.plot_obj.date_axis_info = self.finder(vmin, vmax, self.freq) - - locator = self.plot_obj.date_axis_info + locator = self.finder(vmin, vmax, self.freq) if self.isminor: return np.compress(locator["min"], locator["val"]) @@ -997,9 +994,6 @@ def __call__(self): # axis calls Locator.set_axis inside set_m_formatter vi = tuple(self.axis.get_view_interval()) - if vi != self.plot_obj.view_interval: - self.plot_obj.date_axis_info = None - self.plot_obj.view_interval = vi vmin, vmax = vi if vmax < vmin: vmin, vmax = vmax, vmin @@ -1072,9 +1066,7 @@ def __init__( def _set_default_format(self, vmin, vmax): """Returns the default ticks spacing.""" - if self.plot_obj.date_axis_info is None: - self.plot_obj.date_axis_info = self.finder(vmin, vmax, self.freq) - info = self.plot_obj.date_axis_info + info = self.finder(vmin, vmax, self.freq) if self.isminor: format = np.compress(info["min"] & np.logical_not(info["maj"]), info) @@ -1090,10 +1082,7 @@ def set_locs(self, locs) -> None: self.locs = locs - (vmin, vmax) = vi = tuple(self.axis.get_view_interval()) - if vi != self.plot_obj.view_interval: - self.plot_obj.date_axis_info = None - self.plot_obj.view_interval = vi + (vmin, vmax) = tuple(self.axis.get_view_interval()) if vmax < vmin: (vmin, vmax) = (vmax, vmin) self._set_default_format(vmin, vmax) diff --git a/pandas/plotting/_matplotlib/core.py b/pandas/plotting/_matplotlib/core.py index 6be8284d2a0be..3c96683dca981 100644 --- a/pandas/plotting/_matplotlib/core.py +++ b/pandas/plotting/_matplotlib/core.py @@ -1590,12 +1590,12 @@ def _ts_plot(self, ax: Axes, x, data: Series, style=None, **kwds): freq, data = maybe_resample(data, ax, kwds) # Set ax with freq info - decorate_axes(ax, freq, kwds) + decorate_axes(ax, freq) # digging deeper if hasattr(ax, "left_ax"): - decorate_axes(ax.left_ax, freq, kwds) + decorate_axes(ax.left_ax, freq) if hasattr(ax, "right_ax"): - decorate_axes(ax.right_ax, freq, kwds) + decorate_axes(ax.right_ax, freq) # TODO #54485 ax._plot_data.append((data, self._kind, kwds)) # type: ignore[attr-defined] diff --git a/pandas/plotting/_matplotlib/timeseries.py b/pandas/plotting/_matplotlib/timeseries.py index f0b68e5dde450..6d3579c7f7adb 100644 --- a/pandas/plotting/_matplotlib/timeseries.py +++ b/pandas/plotting/_matplotlib/timeseries.py @@ -111,8 +111,8 @@ def _is_sup(f1: str, f2: str) -> bool: def _upsample_others(ax: Axes, freq: BaseOffset, kwargs: dict[str, Any]) -> None: legend = ax.get_legend() - lines, labels = _replot_ax(ax, freq, kwargs) - _replot_ax(ax, freq, kwargs) + lines, labels = _replot_ax(ax, freq) + _replot_ax(ax, freq) other_ax = None if hasattr(ax, "left_ax"): @@ -121,7 +121,7 @@ def _upsample_others(ax: Axes, freq: BaseOffset, kwargs: dict[str, Any]) -> None other_ax = ax.right_ax if other_ax is not None: - rlines, rlabels = _replot_ax(other_ax, freq, kwargs) + rlines, rlabels = _replot_ax(other_ax, freq) lines.extend(rlines) labels.extend(rlabels) @@ -132,7 +132,7 @@ def _upsample_others(ax: Axes, freq: BaseOffset, kwargs: dict[str, Any]) -> None ax.legend(lines, labels, loc="best", title=title) -def _replot_ax(ax: Axes, freq: BaseOffset, kwargs: dict[str, Any]): +def _replot_ax(ax: Axes, freq: BaseOffset): data = getattr(ax, "_plot_data", None) # clear current axes and data @@ -140,7 +140,7 @@ def _replot_ax(ax: Axes, freq: BaseOffset, kwargs: dict[str, Any]): ax._plot_data = [] # type: ignore[attr-defined] ax.clear() - decorate_axes(ax, freq, kwargs) + decorate_axes(ax, freq) lines = [] labels = [] @@ -164,7 +164,7 @@ def _replot_ax(ax: Axes, freq: BaseOffset, kwargs: dict[str, Any]): return lines, labels -def decorate_axes(ax: Axes, freq: BaseOffset, kwargs: dict[str, Any]) -> None: +def decorate_axes(ax: Axes, freq: BaseOffset) -> None: """Initialize axes for time-series plotting""" if not hasattr(ax, "_plot_data"): # TODO #54485 @@ -175,15 +175,6 @@ def decorate_axes(ax: Axes, freq: BaseOffset, kwargs: dict[str, Any]) -> None: xaxis = ax.get_xaxis() # TODO #54485 xaxis.freq = freq # type: ignore[attr-defined] - if not hasattr(ax, "legendlabels"): - # TODO #54485 - ax.legendlabels = [kwargs.get("label", None)] # type: ignore[attr-defined] - else: - ax.legendlabels.append(kwargs.get("label", None)) - # TODO #54485 - ax.view_interval = None # type: ignore[attr-defined] - # TODO #54485 - ax.date_axis_info = None # type: ignore[attr-defined] def _get_ax_freq(ax: Axes):