MCPcopy
hub / github.com/pandas-dev/pandas / _replot_ax

Function _replot_ax

pandas/plotting/_matplotlib/timeseries.py:131–160  ·  view source on GitHub ↗
(ax: Axes, freq: BaseOffset)

Source from the content-addressed store, hash-verified

129
130
131def _replot_ax(ax: Axes, freq: BaseOffset):
132 data = getattr(ax, "_plot_data", None)
133
134 # clear current axes and data
135 # TODO #54485
136 ax._plot_data = [] # type: ignore[attr-defined]
137 ax.clear()
138
139 decorate_axes(ax, freq)
140
141 lines = []
142 labels = []
143 if data is not None:
144 for series, plotf, kwds in data:
145 series = series.copy(deep=False)
146 idx = series.index.asfreq(freq, how="S")
147 series.index = idx
148 # TODO #54485
149 ax._plot_data.append((series, plotf, kwds)) # type: ignore[attr-defined]
150
151 # for tsplot
152 if isinstance(plotf, str):
153 from pandas.plotting._matplotlib import PLOT_CLASSES
154
155 plotf = PLOT_CLASSES[plotf]._plot
156
157 lines.append(plotf(ax, series.index._mpl_repr(), series.values, **kwds)[0])
158 labels.append(pprint_thing(series.name))
159
160 return lines, labels
161
162
163def decorate_axes(ax: Axes, freq: BaseOffset) -> None:

Callers 1

_upsample_othersFunction · 0.85

Calls 7

pprint_thingFunction · 0.90
decorate_axesFunction · 0.85
clearMethod · 0.80
_mpl_reprMethod · 0.80
copyMethod · 0.45
asfreqMethod · 0.45
appendMethod · 0.45

Tested by

no test coverage detected