diff --git a/doc/source/whatsnew/v1.0.0.rst b/doc/source/whatsnew/v1.0.0.rst index 1032f2e73531da..4ce4c12483b363 100644 --- a/doc/source/whatsnew/v1.0.0.rst +++ b/doc/source/whatsnew/v1.0.0.rst @@ -509,6 +509,10 @@ or ``matplotlib.Axes.plot``. See :ref:`plotting.formatters` for more. **Other removals** +- Removed the previously deprecated :func:`pandas.plotting._matplotlib.tsplot`, use :meth:`Series.plot` instead (:issue:`19980`) +- :func:`pandas.tseries.converter.register` has been moved to :func:`pandas.plotting.register_matplotlib_converters` (:issue:`18307`) +- :meth:`Series.plot` no longer accepts positional arguments, pass keyword arguments instead (:issue:`30003`) +- :meth:`DataFrame.hist` and :meth:`Series.hist` no longer allows ``figsize="default"``, specify figure size by passinig a tuple instead (:issue:`30003`) - Floordiv of integer-dtyped array by :class:`Timedelta` now raises ``TypeError`` (:issue:`21036`) - :func:`pandas.api.types.infer_dtype` argument ``skipna`` defaults to ``True`` instead of ``False`` (:issue:`24050`) - Removed the previously deprecated :meth:`Index.summary` (:issue:`18217`) diff --git a/pandas/plotting/_core.py b/pandas/plotting/_core.py index 375e6fe2b02c7d..dd907457f7c323 100644 --- a/pandas/plotting/_core.py +++ b/pandas/plotting/_core.py @@ -1,5 +1,4 @@ import importlib -import warnings from pandas._config import get_option @@ -752,7 +751,7 @@ def _get_call_args(backend_name, data, args, kwargs): f"Use `Series.plot({keyword_args})` instead of " f"`Series.plot({positional_args})`." ) - warnings.warn(msg, FutureWarning, stacklevel=3) + raise TypeError(msg) pos_args = {name: value for value, (name, _) in zip(args, arg_def)} if backend_name == "pandas.plotting._matplotlib": diff --git a/pandas/plotting/_matplotlib/__init__.py b/pandas/plotting/_matplotlib/__init__.py index 206600ad37acc4..f9a692b0559ca0 100644 --- a/pandas/plotting/_matplotlib/__init__.py +++ b/pandas/plotting/_matplotlib/__init__.py @@ -24,7 +24,6 @@ radviz, scatter_matrix, ) -from pandas.plotting._matplotlib.timeseries import tsplot from pandas.plotting._matplotlib.tools import table PLOT_CLASSES = { @@ -66,7 +65,6 @@ def plot(data, kind, **kwargs): "boxplot", "boxplot_frame", "boxplot_frame_groupby", - "tsplot", "table", "andrews_curves", "autocorrelation_plot", diff --git a/pandas/plotting/_matplotlib/hist.py b/pandas/plotting/_matplotlib/hist.py index b60e8fa8a3f7cb..dc9eede7e4d52b 100644 --- a/pandas/plotting/_matplotlib/hist.py +++ b/pandas/plotting/_matplotlib/hist.py @@ -1,5 +1,3 @@ -import warnings - import numpy as np from pandas.core.dtypes.common import is_integer, is_list_like @@ -182,12 +180,10 @@ def _grouped_plot( if figsize == "default": # allowed to specify mpl default with 'default' - warnings.warn( - "figsize='default' is deprecated. Specify figure size by tuple instead", - FutureWarning, - stacklevel=5, + raise ValueError( + "figsize='default' is no longer supported. " + "Specify figure size by tuple instead" ) - figsize = None grouped = data.groupby(by) if column is not None: diff --git a/pandas/plotting/_matplotlib/timeseries.py b/pandas/plotting/_matplotlib/timeseries.py index fa9585e1fc229d..dd048114142f32 100644 --- a/pandas/plotting/_matplotlib/timeseries.py +++ b/pandas/plotting/_matplotlib/timeseries.py @@ -1,7 +1,6 @@ # TODO: Use the fact that axis can have units to simplify the process import functools -import warnings import numpy as np @@ -25,7 +24,6 @@ TimeSeries_DateFormatter, TimeSeries_DateLocator, TimeSeries_TimedeltaFormatter, - register_pandas_matplotlib_converters, ) import pandas.tseries.frequencies as frequencies from pandas.tseries.offsets import DateOffset @@ -34,49 +32,6 @@ # Plotting functions and monkey patches -@register_pandas_matplotlib_converters -def tsplot(series, plotf, ax=None, **kwargs): - """ - Plots a Series on the given Matplotlib axes or the current axes - - Parameters - ---------- - axes : Axes - series : Series - - Notes - _____ - Supports same kwargs as Axes.plot - - - .. deprecated:: 0.23.0 - Use Series.plot() instead - """ - import matplotlib.pyplot as plt - - warnings.warn( - "'tsplot' is deprecated and will be removed in a " - "future version. Please use Series.plot() instead.", - FutureWarning, - stacklevel=3, - ) - - # Used inferred freq is possible, need a test case for inferred - if ax is None: - ax = plt.gca() - - freq, series = _maybe_resample(series, ax, kwargs) - - # Set ax with freq info - _decorate_axes(ax, freq, kwargs) - ax._plot_data.append((series, plotf, kwargs)) - lines = plotf(ax, series.index._mpl_repr(), series.values, **kwargs) - - # set date formatter, locators and rescale limits - format_dateaxis(ax, ax.freq, series.index) - return lines - - def _maybe_resample(series, ax, kwargs): # resample against axes freq if necessary freq, ax_freq = _get_freq(ax, series) diff --git a/pandas/tests/plotting/test_converter.py b/pandas/tests/plotting/test_converter.py index c2bdea39ae30d1..fb9ad576266000 100644 --- a/pandas/tests/plotting/test_converter.py +++ b/pandas/tests/plotting/test_converter.py @@ -139,15 +139,6 @@ def test_registry_resets(self): for k, v in original.items(): units.registry[k] = v - def test_old_import_warns(self): - with tm.assert_produces_warning(FutureWarning) as w: - from pandas.tseries import converter - - converter.register() - - assert len(w) - assert "pandas.plotting.register_matplotlib_converters" in str(w[0].message) - class TestDateTimeConverter: def setup_method(self, method): diff --git a/pandas/tests/plotting/test_hist_method.py b/pandas/tests/plotting/test_hist_method.py index 14cb2bc9d7b623..6c1c7dfd1a4a4e 100644 --- a/pandas/tests/plotting/test_hist_method.py +++ b/pandas/tests/plotting/test_hist_method.py @@ -313,7 +313,8 @@ def test_grouped_hist_legacy(self): with pytest.raises(AttributeError): _grouped_hist(df.A, by=df.C, foo="bar") - with tm.assert_produces_warning(FutureWarning): + msg = "Specify figure size by tuple instead" + with pytest.raises(ValueError, match=msg): df.hist(by="C", figsize="default") @pytest.mark.slow diff --git a/pandas/tests/plotting/test_misc.py b/pandas/tests/plotting/test_misc.py index c51cd0e92eb3c4..1e59fbf928876a 100644 --- a/pandas/tests/plotting/test_misc.py +++ b/pandas/tests/plotting/test_misc.py @@ -32,14 +32,9 @@ def test_get_accessor_args(): with pytest.raises(TypeError, match=msg): func(backend_name="", data=[], args=[], kwargs={}) - with tm.assert_produces_warning(FutureWarning, check_stacklevel=False): - x, y, kind, kwargs = func( - backend_name="", data=Series(), args=["line", None], kwargs={} - ) - assert x is None - assert y is None - assert kind == "line" - assert kwargs == {"ax": None} + msg = "should not be called with positional arguments" + with pytest.raises(TypeError, match=msg): + func(backend_name="", data=Series(), args=["line", None], kwargs={}) x, y, kind, kwargs = func( backend_name="", diff --git a/pandas/tseries/converter.py b/pandas/tseries/converter.py deleted file mode 100644 index ac80215e01ed54..00000000000000 --- a/pandas/tseries/converter.py +++ /dev/null @@ -1,32 +0,0 @@ -# flake8: noqa -import warnings - -# TODO `_matplotlib` module should be private, so the plotting backend -# can be changed. Decide whether all these should be public and exposed -# in `pandas.plotting`, or remove from here (I guess they are here for -# legacy reasons) -from pandas.plotting._matplotlib.converter import ( - DatetimeConverter, - MilliSecondLocator, - PandasAutoDateFormatter, - PandasAutoDateLocator, - PeriodConverter, - TimeConverter, - TimeFormatter, - TimeSeries_DateFormatter, - TimeSeries_DateLocator, - get_datevalue, - get_finder, - time2num, -) - - -def register(): - from pandas.plotting import register_matplotlib_converters - - msg = ( - "'pandas.tseries.converter.register' has been moved and renamed to " - "'pandas.plotting.register_matplotlib_converters'. " - ) - warnings.warn(msg, FutureWarning, stacklevel=2) - register_matplotlib_converters()