Skip to content

Commit 434d84d

Browse files
committed
REF: Remove un-used attribute-pinning in plotting
1 parent 76d28c7 commit 434d84d

File tree

3 files changed

+12
-29
lines changed

3 files changed

+12
-29
lines changed

pandas/plotting/_matplotlib/converter.py

+3-14
Original file line numberDiff line numberDiff line change
@@ -973,10 +973,7 @@ def __init__(
973973

974974
def _get_default_locs(self, vmin, vmax):
975975
"""Returns the default locations of ticks."""
976-
if self.plot_obj.date_axis_info is None:
977-
self.plot_obj.date_axis_info = self.finder(vmin, vmax, self.freq)
978-
979-
locator = self.plot_obj.date_axis_info
976+
locator = self.finder(vmin, vmax, self.freq)
980977

981978
if self.isminor:
982979
return np.compress(locator["min"], locator["val"])
@@ -987,9 +984,6 @@ def __call__(self):
987984
# axis calls Locator.set_axis inside set_m<xxxx>_formatter
988985

989986
vi = tuple(self.axis.get_view_interval())
990-
if vi != self.plot_obj.view_interval:
991-
self.plot_obj.date_axis_info = None
992-
self.plot_obj.view_interval = vi
993987
vmin, vmax = vi
994988
if vmax < vmin:
995989
vmin, vmax = vmax, vmin
@@ -1058,9 +1052,7 @@ def __init__(
10581052

10591053
def _set_default_format(self, vmin, vmax):
10601054
"""Returns the default ticks spacing."""
1061-
if self.plot_obj.date_axis_info is None:
1062-
self.plot_obj.date_axis_info = self.finder(vmin, vmax, self.freq)
1063-
info = self.plot_obj.date_axis_info
1055+
info = self.finder(vmin, vmax, self.freq)
10641056

10651057
if self.isminor:
10661058
format = np.compress(info["min"] & np.logical_not(info["maj"]), info)
@@ -1076,10 +1068,7 @@ def set_locs(self, locs) -> None:
10761068

10771069
self.locs = locs
10781070

1079-
(vmin, vmax) = vi = tuple(self.axis.get_view_interval())
1080-
if vi != self.plot_obj.view_interval:
1081-
self.plot_obj.date_axis_info = None
1082-
self.plot_obj.view_interval = vi
1071+
(vmin, vmax) = tuple(self.axis.get_view_interval())
10831072
if vmax < vmin:
10841073
(vmin, vmax) = (vmax, vmin)
10851074
self._set_default_format(vmin, vmax)

pandas/plotting/_matplotlib/core.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -1578,12 +1578,12 @@ def _ts_plot(self, ax: Axes, x, data: Series, style=None, **kwds):
15781578
freq, data = maybe_resample(data, ax, kwds)
15791579

15801580
# Set ax with freq info
1581-
decorate_axes(ax, freq, kwds)
1581+
decorate_axes(ax, freq)
15821582
# digging deeper
15831583
if hasattr(ax, "left_ax"):
1584-
decorate_axes(ax.left_ax, freq, kwds)
1584+
decorate_axes(ax.left_ax, freq)
15851585
if hasattr(ax, "right_ax"):
1586-
decorate_axes(ax.right_ax, freq, kwds)
1586+
decorate_axes(ax.right_ax, freq)
15871587
ax._plot_data.append((data, self._kind, kwds))
15881588

15891589
lines = self._plot(ax, data.index, np.asarray(data.values), style=style, **kwds)

pandas/plotting/_matplotlib/timeseries.py

+6-12
Original file line numberDiff line numberDiff line change
@@ -104,8 +104,8 @@ def _is_sup(f1: str, f2: str) -> bool:
104104

105105
def _upsample_others(ax: Axes, freq: BaseOffset, kwargs: dict[str, Any]) -> None:
106106
legend = ax.get_legend()
107-
lines, labels = _replot_ax(ax, freq, kwargs)
108-
_replot_ax(ax, freq, kwargs)
107+
lines, labels = _replot_ax(ax, freq)
108+
_replot_ax(ax, freq)
109109

110110
other_ax = None
111111
if hasattr(ax, "left_ax"):
@@ -114,7 +114,7 @@ def _upsample_others(ax: Axes, freq: BaseOffset, kwargs: dict[str, Any]) -> None
114114
other_ax = ax.right_ax
115115

116116
if other_ax is not None:
117-
rlines, rlabels = _replot_ax(other_ax, freq, kwargs)
117+
rlines, rlabels = _replot_ax(other_ax, freq)
118118
lines.extend(rlines)
119119
labels.extend(rlabels)
120120

@@ -125,14 +125,14 @@ def _upsample_others(ax: Axes, freq: BaseOffset, kwargs: dict[str, Any]) -> None
125125
ax.legend(lines, labels, loc="best", title=title)
126126

127127

128-
def _replot_ax(ax: Axes, freq: BaseOffset, kwargs: dict[str, Any]):
128+
def _replot_ax(ax: Axes, freq: BaseOffset):
129129
data = getattr(ax, "_plot_data", None)
130130

131131
# clear current axes and data
132132
ax._plot_data = []
133133
ax.clear()
134134

135-
decorate_axes(ax, freq, kwargs)
135+
decorate_axes(ax, freq)
136136

137137
lines = []
138138
labels = []
@@ -155,20 +155,14 @@ def _replot_ax(ax: Axes, freq: BaseOffset, kwargs: dict[str, Any]):
155155
return lines, labels
156156

157157

158-
def decorate_axes(ax: Axes, freq: BaseOffset, kwargs: dict[str, Any]) -> None:
158+
def decorate_axes(ax: Axes, freq: BaseOffset) -> None:
159159
"""Initialize axes for time-series plotting"""
160160
if not hasattr(ax, "_plot_data"):
161161
ax._plot_data = []
162162

163163
ax.freq = freq
164164
xaxis = ax.get_xaxis()
165165
xaxis.freq = freq
166-
if not hasattr(ax, "legendlabels"):
167-
ax.legendlabels = [kwargs.get("label", None)]
168-
else:
169-
ax.legendlabels.append(kwargs.get("label", None))
170-
ax.view_interval = None
171-
ax.date_axis_info = None
172166

173167

174168
def _get_ax_freq(ax: Axes):

0 commit comments

Comments
 (0)