diff --git a/doc/api/next_api_changes/deprecations.rst b/doc/api/next_api_changes/deprecations.rst index 3837598f0852..dae361ec5f6b 100644 --- a/doc/api/next_api_changes/deprecations.rst +++ b/doc/api/next_api_changes/deprecations.rst @@ -150,3 +150,12 @@ and containment checks) via `.Line2D.set_picker` is deprecated. Use The ``on_mappable_changed`` and ``update_bruteforce`` methods of `~matplotlib.colorbar.Colorbar` are deprecated; both can be replaced by calls to `~matplotlib.colorbar.Colorbar.update_normal`. + +``OldScalarFormatter``, ``IndexFormatter`` and ``DateIndexFormatter`` +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +These formatters are deprecated. Their functionality can be implemented using +e.g. `.FuncFormatter`. + +``OldAutoLocator`` +~~~~~~~~~~~~~~~~~~ +This ticker is deprecated. diff --git a/lib/matplotlib/dates.py b/lib/matplotlib/dates.py index fca6664ab21d..32de2a7839a2 100644 --- a/lib/matplotlib/dates.py +++ b/lib/matplotlib/dates.py @@ -604,6 +604,7 @@ def set_tzinfo(self, tz): self.tz = tz +@cbook.deprecated("3.3") class IndexDateFormatter(ticker.Formatter): """Use with `.IndexLocator` to cycle format strings by index.""" diff --git a/lib/matplotlib/tests/test_ticker.py b/lib/matplotlib/tests/test_ticker.py index 5a3ed56a46c8..4e741b086a1b 100644 --- a/lib/matplotlib/tests/test_ticker.py +++ b/lib/matplotlib/tests/test_ticker.py @@ -10,6 +10,7 @@ import pytest import matplotlib +from matplotlib import cbook import matplotlib.pyplot as plt import matplotlib.ticker as mticker @@ -457,7 +458,8 @@ class TestIndexFormatter: (2, 'label2'), (2.5, '')]) def test_formatting(self, x, label): - formatter = mticker.IndexFormatter(['label0', 'label1', 'label2']) + with cbook._suppress_matplotlib_deprecation_warning(): + formatter = mticker.IndexFormatter(['label0', 'label1', 'label2']) assert formatter(x) == label diff --git a/lib/matplotlib/ticker.py b/lib/matplotlib/ticker.py index 856e280a04ad..b1c73477f87e 100644 --- a/lib/matplotlib/ticker.py +++ b/lib/matplotlib/ticker.py @@ -293,6 +293,7 @@ def _set_locator(self, locator): pass +@cbook.deprecated("3.3") class IndexFormatter(Formatter): """ Format the position x to the nearest i-th label where ``i = int(x + 0.5)``. @@ -322,13 +323,10 @@ def __call__(self, x, pos=None): class NullFormatter(Formatter): - """ - Always return the empty string. - """ + """Always return the empty string.""" + def __call__(self, x, pos=None): - """ - Returns an empty string for all inputs. - """ + # docstring inherited return '' @@ -428,6 +426,7 @@ def __call__(self, x, pos=None): return self.fmt.format(x=x, pos=pos) +@cbook.deprecated("3.3") class OldScalarFormatter(Formatter): """ Tick location is a plain old number. @@ -2867,6 +2866,7 @@ def tick_values(self, vmin, vmax): '%s type.' % type(self)) +@cbook.deprecated("3.3") class OldAutoLocator(Locator): """ On autoscale this class picks the best MultipleLocator to set the