Skip to content

Commit 00a2a0e

Browse files
jbrockmendeljreback
authored andcommitted
DEPR: plotting deprecations (#30003)
1 parent 8b31f9b commit 00a2a0e

File tree

9 files changed

+13
-106
lines changed

9 files changed

+13
-106
lines changed

doc/source/whatsnew/v1.0.0.rst

+4
Original file line numberDiff line numberDiff line change
@@ -509,6 +509,10 @@ or ``matplotlib.Axes.plot``. See :ref:`plotting.formatters` for more.
509509

510510
**Other removals**
511511

512+
- Removed the previously deprecated :func:`pandas.plotting._matplotlib.tsplot`, use :meth:`Series.plot` instead (:issue:`19980`)
513+
- :func:`pandas.tseries.converter.register` has been moved to :func:`pandas.plotting.register_matplotlib_converters` (:issue:`18307`)
514+
- :meth:`Series.plot` no longer accepts positional arguments, pass keyword arguments instead (:issue:`30003`)
515+
- :meth:`DataFrame.hist` and :meth:`Series.hist` no longer allows ``figsize="default"``, specify figure size by passinig a tuple instead (:issue:`30003`)
512516
- Floordiv of integer-dtyped array by :class:`Timedelta` now raises ``TypeError`` (:issue:`21036`)
513517
- :func:`pandas.api.types.infer_dtype` argument ``skipna`` defaults to ``True`` instead of ``False`` (:issue:`24050`)
514518
- Removed the previously deprecated :meth:`Index.summary` (:issue:`18217`)

pandas/plotting/_core.py

+1-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import importlib
2-
import warnings
32

43
from pandas._config import get_option
54

@@ -752,7 +751,7 @@ def _get_call_args(backend_name, data, args, kwargs):
752751
f"Use `Series.plot({keyword_args})` instead of "
753752
f"`Series.plot({positional_args})`."
754753
)
755-
warnings.warn(msg, FutureWarning, stacklevel=3)
754+
raise TypeError(msg)
756755

757756
pos_args = {name: value for value, (name, _) in zip(args, arg_def)}
758757
if backend_name == "pandas.plotting._matplotlib":

pandas/plotting/_matplotlib/__init__.py

-2
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@
2424
radviz,
2525
scatter_matrix,
2626
)
27-
from pandas.plotting._matplotlib.timeseries import tsplot
2827
from pandas.plotting._matplotlib.tools import table
2928

3029
PLOT_CLASSES = {
@@ -66,7 +65,6 @@ def plot(data, kind, **kwargs):
6665
"boxplot",
6766
"boxplot_frame",
6867
"boxplot_frame_groupby",
69-
"tsplot",
7068
"table",
7169
"andrews_curves",
7270
"autocorrelation_plot",

pandas/plotting/_matplotlib/hist.py

+3-7
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
import warnings
2-
31
import numpy as np
42

53
from pandas.core.dtypes.common import is_integer, is_list_like
@@ -182,12 +180,10 @@ def _grouped_plot(
182180

183181
if figsize == "default":
184182
# allowed to specify mpl default with 'default'
185-
warnings.warn(
186-
"figsize='default' is deprecated. Specify figure size by tuple instead",
187-
FutureWarning,
188-
stacklevel=5,
183+
raise ValueError(
184+
"figsize='default' is no longer supported. "
185+
"Specify figure size by tuple instead"
189186
)
190-
figsize = None
191187

192188
grouped = data.groupby(by)
193189
if column is not None:

pandas/plotting/_matplotlib/timeseries.py

-45
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
# TODO: Use the fact that axis can have units to simplify the process
22

33
import functools
4-
import warnings
54

65
import numpy as np
76

@@ -25,7 +24,6 @@
2524
TimeSeries_DateFormatter,
2625
TimeSeries_DateLocator,
2726
TimeSeries_TimedeltaFormatter,
28-
register_pandas_matplotlib_converters,
2927
)
3028
import pandas.tseries.frequencies as frequencies
3129
from pandas.tseries.offsets import DateOffset
@@ -34,49 +32,6 @@
3432
# Plotting functions and monkey patches
3533

3634

37-
@register_pandas_matplotlib_converters
38-
def tsplot(series, plotf, ax=None, **kwargs):
39-
"""
40-
Plots a Series on the given Matplotlib axes or the current axes
41-
42-
Parameters
43-
----------
44-
axes : Axes
45-
series : Series
46-
47-
Notes
48-
_____
49-
Supports same kwargs as Axes.plot
50-
51-
52-
.. deprecated:: 0.23.0
53-
Use Series.plot() instead
54-
"""
55-
import matplotlib.pyplot as plt
56-
57-
warnings.warn(
58-
"'tsplot' is deprecated and will be removed in a "
59-
"future version. Please use Series.plot() instead.",
60-
FutureWarning,
61-
stacklevel=3,
62-
)
63-
64-
# Used inferred freq is possible, need a test case for inferred
65-
if ax is None:
66-
ax = plt.gca()
67-
68-
freq, series = _maybe_resample(series, ax, kwargs)
69-
70-
# Set ax with freq info
71-
_decorate_axes(ax, freq, kwargs)
72-
ax._plot_data.append((series, plotf, kwargs))
73-
lines = plotf(ax, series.index._mpl_repr(), series.values, **kwargs)
74-
75-
# set date formatter, locators and rescale limits
76-
format_dateaxis(ax, ax.freq, series.index)
77-
return lines
78-
79-
8035
def _maybe_resample(series, ax, kwargs):
8136
# resample against axes freq if necessary
8237
freq, ax_freq = _get_freq(ax, series)

pandas/tests/plotting/test_converter.py

-9
Original file line numberDiff line numberDiff line change
@@ -139,15 +139,6 @@ def test_registry_resets(self):
139139
for k, v in original.items():
140140
units.registry[k] = v
141141

142-
def test_old_import_warns(self):
143-
with tm.assert_produces_warning(FutureWarning) as w:
144-
from pandas.tseries import converter
145-
146-
converter.register()
147-
148-
assert len(w)
149-
assert "pandas.plotting.register_matplotlib_converters" in str(w[0].message)
150-
151142

152143
class TestDateTimeConverter:
153144
def setup_method(self, method):

pandas/tests/plotting/test_hist_method.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -313,7 +313,8 @@ def test_grouped_hist_legacy(self):
313313
with pytest.raises(AttributeError):
314314
_grouped_hist(df.A, by=df.C, foo="bar")
315315

316-
with tm.assert_produces_warning(FutureWarning):
316+
msg = "Specify figure size by tuple instead"
317+
with pytest.raises(ValueError, match=msg):
317318
df.hist(by="C", figsize="default")
318319

319320
@pytest.mark.slow

pandas/tests/plotting/test_misc.py

+3-8
Original file line numberDiff line numberDiff line change
@@ -32,14 +32,9 @@ def test_get_accessor_args():
3232
with pytest.raises(TypeError, match=msg):
3333
func(backend_name="", data=[], args=[], kwargs={})
3434

35-
with tm.assert_produces_warning(FutureWarning, check_stacklevel=False):
36-
x, y, kind, kwargs = func(
37-
backend_name="", data=Series(), args=["line", None], kwargs={}
38-
)
39-
assert x is None
40-
assert y is None
41-
assert kind == "line"
42-
assert kwargs == {"ax": None}
35+
msg = "should not be called with positional arguments"
36+
with pytest.raises(TypeError, match=msg):
37+
func(backend_name="", data=Series(), args=["line", None], kwargs={})
4338

4439
x, y, kind, kwargs = func(
4540
backend_name="",

pandas/tseries/converter.py

-32
This file was deleted.

0 commit comments

Comments
 (0)