Skip to content

Commit

Permalink
DEPR: plotting deprecations (#30003)
Browse files Browse the repository at this point in the history
  • Loading branch information
jbrockmendel authored and jreback committed Dec 5, 2019
1 parent 8b31f9b commit 00a2a0e
Show file tree
Hide file tree
Showing 9 changed files with 13 additions and 106 deletions.
4 changes: 4 additions & 0 deletions doc/source/whatsnew/v1.0.0.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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`)
Expand Down
3 changes: 1 addition & 2 deletions pandas/plotting/_core.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import importlib
import warnings

from pandas._config import get_option

Expand Down Expand Up @@ -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":
Expand Down
2 changes: 0 additions & 2 deletions pandas/plotting/_matplotlib/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@
radviz,
scatter_matrix,
)
from pandas.plotting._matplotlib.timeseries import tsplot
from pandas.plotting._matplotlib.tools import table

PLOT_CLASSES = {
Expand Down Expand Up @@ -66,7 +65,6 @@ def plot(data, kind, **kwargs):
"boxplot",
"boxplot_frame",
"boxplot_frame_groupby",
"tsplot",
"table",
"andrews_curves",
"autocorrelation_plot",
Expand Down
10 changes: 3 additions & 7 deletions pandas/plotting/_matplotlib/hist.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
import warnings

import numpy as np

from pandas.core.dtypes.common import is_integer, is_list_like
Expand Down Expand Up @@ -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:
Expand Down
45 changes: 0 additions & 45 deletions pandas/plotting/_matplotlib/timeseries.py
Original file line number Diff line number Diff line change
@@ -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

Expand All @@ -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
Expand All @@ -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)
Expand Down
9 changes: 0 additions & 9 deletions pandas/tests/plotting/test_converter.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down
3 changes: 2 additions & 1 deletion pandas/tests/plotting/test_hist_method.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
11 changes: 3 additions & 8 deletions pandas/tests/plotting/test_misc.py
Original file line number Diff line number Diff line change
Expand Up @@ -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="",
Expand Down
32 changes: 0 additions & 32 deletions pandas/tseries/converter.py

This file was deleted.

0 comments on commit 00a2a0e

Please sign in to comment.