Skip to content

Remove deprecations that expire in 3.3 #17239

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 10 commits into from
Apr 27, 2020
22 changes: 22 additions & 0 deletions doc/api/api_changes_3.3/behaviour.rst
Original file line number Diff line number Diff line change
Expand Up @@ -192,3 +192,25 @@ be kept by passing it as a keyword argument to `.Axes.hist`.
`.Legend` and `.OffsetBox` subclasses (`.PaddedBox`, `.AnchoredOffsetbox`, and
`.AnnotationBbox`) no longer directly keep track of the visibility of their
underlying `.Patch` artist, but instead pass that flag down to the `.Patch`.

`.Legend` and `.Table` no longer allow invalid locations
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
This affects legends produced on an Axes (`.Axes.legend` and `.pyplot.legend`)
and on a Figure (`.Figure.legend` and `.pyplot.figlegend`). Figure legends also
no longer accept the unsupported ``'best'`` location. Previously, invalid Axes
locations would use ``'best'`` and invalid Figure locations would used ``'upper
right'``.


Passing Line2D's *drawstyle* together with *linestyle* is removed
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Instead of ``plt.plot(..., linestyle="steps--")``, use ``plt.plot(...,
linestyle="--", drawstyle="steps")``. ``ds`` is also an alias for
``drawstyle``.

Upper case color strings
~~~~~~~~~~~~~~~~~~~~~~~~

Support for passing single-letter colors (one of "rgbcmykw") as UPPERCASE
characters is removed; these colors are now case-sensitive (lowercase).
108 changes: 68 additions & 40 deletions doc/api/api_changes_3.3/removals.rst
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,12 @@ Modules

Classes, methods and attributes
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- ``artist.Artist.aname`` property (no replacement)

- ``axis.Axis.iter_ticks`` (no replacement)

- Support for custom backends that do not provide a
``backend_bases.GraphicsContextBase.set_hatch_color`` method
- ``backend_bases.RendererBase.strip_math()``
(use ``cbook.strip_math()`` instead)

Expand Down Expand Up @@ -39,38 +45,68 @@ Classes, methods and attributes
- ``backend_qt5.NavigationToolbar2QT.buttons`` property (no replacement)
- ``backend_qt5.NavigationToolbar2QT.adj_window`` property (no replacement)

- ``bezier.find_r_to_boundary_of_closedpath()`` (no replacement)

- ``cbook.dedent()`` (use `inspect.cleandoc` instead)
- ``cbook.get_label()`` (no replacement)
- ``cbook.is_hashable()`` (use ``isinstance(..., collections.abc.Hashable)``
instead)
- ``cbook.iterable()`` (use ``numpy.iterable()`` instead)
- ``cbook.safezip()`` (no replacement)

- ``colorbar.ColorbarBase.get_cmap`` (use ``ScalarMappable.get_cmap`` instead)
- ``colorbar.ColorbarBase.set_cmap`` (use ``ScalarMappable.set_cmap`` instead)
- ``colorbar.ColorbarBase.get_clim`` (use ``ScalarMappable.get_clim`` instead)
- ``colorbar.ColorbarBase.set_clim`` (use ``ScalarMappable.set_clim`` instead)
- ``colorbar.ColorbarBase.set_norm`` (use ``ScalarMappable.set_norm`` instead)

- ``dates.seconds()`` (no replacement)
- ``dates.minutes()`` (no replacement)
- ``dates.hours()`` (no replacement)
- ``dates.weeks()`` (no replacement)
- ``dates.strpdate2num`` and ``dates.bytespdate2num`` (use `time.strptime` or
`dateutil.parser.parse` or `.dates.datestr2num` instead)

- ``docstring.Appender`` (no replacement)
- ``docstring.dedent()`` (use `inspect.getdoc` instead)
- ``docstring.copy_dedent()``
(use ``docstring.copy()`` and `inspect.getdoc` instead)

- ``font_manager.OSXInstalledFonts()`` (no replacement)

- ``image.BboxImage.interp_at_native`` property (no replacement)

- ``lines.Line2D.verticalOffset`` property (no replacement)

- ``matplotlib.checkdep_dvipng`` (no replacement)
- ``matplotlib.checkdep_ghostscript`` (no replacement)
- ``matplotlib.checkdep_pdftops`` (no replacement)
- ``matplotlib.checkdep_inkscape`` (no replacement)
- ``matplotlib.get_py2exe_datafiles`` (no replacement)
- ``matplotlib.tk_window_focus`` (use ``rcParams['tk.window_focus']`` instead)

- ``mlab.demean()`` (use ``mlab.detrend_mean()`` instead)

- ``path.get_paths_extents()``
(use ``path.get_path_collection_extents()`` instead)
- ``path.Path.has_nonfinite()`` (use ``not np.isfinite(self.vertices).all()``
instead)

- ``projections.process_projection_requirements()`` (no replacement)

- ``pyplot.plotfile()`` (Instead, load the data using
`pandas.read_csv` or `numpy.loadtxt` or similar and use regular pyplot
functions to plot the loaded data.)

- ``quiver.Quiver.color()`` (use ``Quiver.get_facecolor()`` instead)
- ``quiver.Quiver.keyvec`` property (no replacement)
- ``quiver.Quiver.keytext`` property (no replacement)

- ``rcsetup.validate_qt4()`` (no replacement)
- ``rcsetup.validate_qt5()`` (no replacement)
- ``rcsetup.validate_verbose()`` (no replacement)
- ``rcsetup.ValidateInterval`` (no replacement)

- ``sphinxext.plot_directive.plot_directive()``
(use the class ``PlotDirective`` instead)
- ``sphinxext.mathmpl.math_directive()``
(use the class ``MathDirective`` instead)

- ``scale.LogTransformBase`` (use ``scale.LogTransform`` instead)
- ``scale.InvertedLogTransformBase`` (use ``scale.InvertedLogTransform`` instead)
- ``scale.Log10Transform`` (use ``scale.LogTransform`` instead)
Expand All @@ -79,15 +115,27 @@ Classes, methods and attributes
- ``scale.InvertedLog2Transform`` (use ``scale.InvertedLogTransform`` instead)
- ``scale.NaturalLogTransform`` (use ``scale.LogTransform`` instead)
- ``scale.InvertedNaturalLogTransform`` (use ``scale.InvertedLogTransform`` instead)
- ``scale.get_scale_docs()`` (no replacement)

- ``sphinxext.plot_directive.plot_directive()``
(use the class ``PlotDirective`` instead)
- ``sphinxext.mathmpl.math_directive()``
(use the class ``MathDirective`` instead)

- ``spines.Spine.is_frame_like()`` (no replacement)

- ``testing.decorators.switch_backend()`` (use ``@pytest.mark.backend``
decorator instead)

- ``text.Text.is_math_text()`` (use ``cbook.is_math_text()`` instead)
- ``text.TextWithDash()`` (use ``text.Annotation`` instead)
- ``textpath.TextPath.is_math_text()`` (use ``cbook.is_math_text()`` instead)
- ``textpath.TextPath.text_get_vertices_codes()``
(use ``textpath.text_to_path.get_text_path()`` instead)

- ``textpath.TextToPath.glyph_to_path()`` (use ``font.get_path()`` and manual
translation of the vertices instead)

- ``ticker.OldScalarFormatter.pprint_val()`` (no replacement)
- ``ticker.ScalarFormatter.pprint_val()`` (no replacement)
- ``ticker.LogFormatter.pprint_val()`` (no replacement)
Expand All @@ -98,38 +146,7 @@ Classes, methods and attributes
``Tick.tick1line``, ``Tick.tick2line``, ``Tick.label1``, ``Tick.label2``
instead)

- ``Artist.aname`` property (no replacement)
- ``Axis.iter_ticks`` (no replacement)

- ``image.BboxImage.interp_at_native`` property (no replacement)
- ``lines.Line2D.verticalOffset`` property (no replacement)
- ``bezier.find_r_to_boundary_of_closedpath()`` (no replacement)

- ``quiver.Quiver.color()`` (use ``Quiver.get_facecolor()`` instead)
- ``quiver.Quiver.keyvec`` property (no replacement)
- ``quiver.Quiver.keytext`` property (no replacement)

- ``colorbar.ColorbarBase.get_cmap`` (use ``ScalarMappable.get_cmap`` instead)
- ``colorbar.ColorbarBase.set_cmap`` (use ``ScalarMappable.set_cmap`` instead)
- ``colorbar.ColorbarBase.get_clim`` (use ``ScalarMappable.get_clim`` instead)
- ``colorbar.ColorbarBase.set_clim`` (use ``ScalarMappable.set_clim`` instead)
- ``colorbar.ColorbarBase.set_norm`` (use ``ScalarMappable.set_norm`` instead)

- ``dates.seconds()`` (no replacement)
- ``dates.minutes()`` (no replacement)
- ``dates.hours()`` (no replacement)
- ``dates.weeks()`` (no replacement)
- ``dates.strpdate2num`` and ``dates.bytespdate2num`` (use `time.strptime` or
`dateutil.parser.parse` or `.dates.datestr2num` instead)

- ``font_manager.OSXInstalledFonts()`` (no replacement)

- ``mlab.demean()`` (use ``mlab.detrend_mean()`` instead)

- ``projections.process_projection_requirements()`` (no replacement)

- ``path.get_paths_extents()``
(use ``path.get_path_collection_extents()`` instead)
- ``widgets.SpanSelector.buttonDown`` property (no replacement)

- ``mplot3d.proj3d.line2d()`` (no replacement)
- ``mplot3d.proj3d.line2d_dist()`` (no replacement)
Expand Down Expand Up @@ -159,8 +176,6 @@ Classes, methods and attributes
- ``axisartist.axislines.Axes.AxisDict``
(use ``axis_grid1.mpl_axes.Axes.AxisDict`` instead)

- ``widgets.SpanSelector.buttonDown`` property (no replacement)

Arguments
~~~~~~~~~
- ``Axes.text()`` / ``pyplot.text()`` do not support the parameter ``withdash``
Expand All @@ -176,7 +191,8 @@ Arguments
- The unused parameter ``interp_at_native`` of `.BboxImage` has been removed.
- The parameter ``usetex`` of `.TextToPath.get_text_path` has been removed.
Use ``ismath='TeX'`` instead.
- The parameter ``block`` of ``show()`` is now keyword-only.
- The parameter ``block`` of ``show()`` is now keyword-only, and arbitrary
arguments or keyword arguments are no longer accepted.
- The parameter ``frameon`` of `.Figure.savefig` has been removed. Use
``facecolor="none"`` to get a transparent background.
- Passing a ``wx.EvtHandler`` as the first argument to ``backend_wx.TimerWx``
Expand All @@ -195,6 +211,18 @@ Arguments
other than ``ticklabels``.
- ``mpl_toolkits.mplot3d.art3d.Poly3DCollection.set_zsort`` does not accept
the value ``True`` anymore. Pass the equivalent value 'average' instead.
- `.AnchoredText` no longer accepts ``horizontalalignment`` or
``verticalalignment`` keyword arguments.
- `.ConnectionPatch` no longer accepts the ``arrow_transmuter`` and
``connector`` keyword arguments, which did nothing since 3.0.
- `.FancyArrowPatch` no longer accepts the ``arrow_transmuter`` and
``connector`` keyword arguments, which did nothing since 3.0.
- `.TextPath` no longer accepts arbitrary positional or keyword arguments.
- `.MaxNLocator.set_params()` no longer accepts arbitrary keyword arguments.
- `~.Axes.pie` no longer accepts and squeezes non-1D inputs; pass 1D input to
the ``x`` argument.
- Passing (n, 1)-shaped error arrays to `.Axes.errorbar()` is no longer
supported; pass a 1D array instead.

rcParams
~~~~~~~~
Expand Down
9 changes: 5 additions & 4 deletions doc/api/prev_api_changes/api_changes_3.1.0.rst
Original file line number Diff line number Diff line change
Expand Up @@ -849,8 +849,8 @@ Use the standard library's docstring manipulation tools instead, such as



- `matplotlib.scale.get_scale_docs()`
- `matplotlib.pyplot.get_scale_docs()`
- ``matplotlib.scale.get_scale_docs()``
- ``matplotlib.pyplot.get_scale_docs()``

These are considered internal and will be removed from the public API in a
future version.
Expand Down Expand Up @@ -905,7 +905,8 @@ Font Handling
- ``backend_pdf.RendererPdf.afm_font_cache``
- ``backend_ps.RendererPS.afmfontd``
- ``font_manager.OSXInstalledFonts``
- `.TextToPath.glyph_to_path` (Instead call ``font.get_path()`` and manually transform the path.)
- ``.TextToPath.glyph_to_path`` (Instead call ``font.get_path()`` and manually
transform the path.)


Date related functions
Expand Down Expand Up @@ -1011,7 +1012,7 @@ Path tools

Use `~.path.get_path_collection_extents` instead.

- `.Path.has_nonfinite` attribute
- ``.Path.has_nonfinite`` attribute

Use ``not np.isfinite(path.vertices).all()`` instead.

Expand Down
5 changes: 1 addition & 4 deletions doc/missing-references.json
Original file line number Diff line number Diff line change
Expand Up @@ -1369,9 +1369,6 @@
"matplotlib.patches.Patch.__init__": [
"doc/devel/documenting_mpl.rst:696"
],
"matplotlib.pyplot.get_scale_docs()": [
"doc/api/prev_api_changes/api_changes_3.1.0.rst:853"
],
"matplotlib.sphinxext.mathmpl": [
"doc/users/prev_whats_new/whats_new_3.0.rst:225"
],
Expand Down Expand Up @@ -1543,4 +1540,4 @@
"lib/mpl_toolkits/mplot3d/axes3d.py:docstring of mpl_toolkits.mplot3d.axes3d.Axes3D.get_ylim3d:24"
]
}
}
}
31 changes: 8 additions & 23 deletions lib/matplotlib/axes/_axes.py
Original file line number Diff line number Diff line change
Expand Up @@ -2915,7 +2915,7 @@ def pie(self, x, explode=None, labels=None, colors=None,

Parameters
----------
x : array-like
x : 1D array-like
The wedge sizes.

explode : array-like, default: None
Expand Down Expand Up @@ -2999,12 +2999,8 @@ def pie(self, x, explode=None, labels=None, colors=None,
# The use of float32 is "historical", but can't be changed without
# regenerating the test baselines.
x = np.asarray(x, np.float32)
if x.ndim != 1 and x.squeeze().ndim <= 1:
cbook.warn_deprecated(
"3.1", message="Non-1D inputs to pie() are currently "
"squeeze()d, but this behavior is deprecated since %(since)s "
"and will be removed %(removal)s; pass a 1D array instead.")
x = np.atleast_1d(x.squeeze())
if x.ndim > 1:
raise ValueError("x must be 1D")

if np.any(x < 0):
raise ValueError("Wedge sizes 'x' must be non negative values")
Expand Down Expand Up @@ -3372,7 +3368,7 @@ def xywhere(xs, ys, mask):
ys = [thisy for thisy, b in zip(ys, mask) if b]
return xs, ys

def extract_err(err, data):
def extract_err(name, err, data):
"""
Private function to parse *err* and subtract/add it to *data*.

Expand All @@ -3384,20 +3380,9 @@ def extract_err(err, data):
iter(b)
except (TypeError, ValueError):
a = b = err # Symmetric error: 1D iterable.
# This could just be `np.ndim(a) > 1 and np.ndim(b) > 1`, except
# for the (undocumented, but tested) support for (n, 1) arrays.
a_sh = np.shape(a)
b_sh = np.shape(b)
if (len(a_sh) > 2 or (len(a_sh) == 2 and a_sh[1] != 1)
or len(b_sh) > 2 or (len(b_sh) == 2 and b_sh[1] != 1)):
if np.ndim(a) > 1 or np.ndim(b) > 1:
raise ValueError(
"err must be a scalar or a 1D or (2, n) array-like")
if len(a_sh) == 2 or len(b_sh) == 2:
cbook.warn_deprecated(
"3.1", message="Support for passing a (n, 1)-shaped error "
"array to errorbar() is deprecated since Matplotlib "
"%(since)s and will be removed %(removal)s; pass a 1D "
"array instead.")
f"{name}err must be a scalar or a 1D or (2, n) array-like")
# Using list comprehensions rather than arrays to preserve units.
for e in [a, b]:
if len(data) != len(e):
Expand All @@ -3409,7 +3394,7 @@ def extract_err(err, data):
return low, high

if xerr is not None:
left, right = extract_err(xerr, x)
left, right = extract_err('x', xerr, x)
# select points without upper/lower limits in x and
# draw normal errorbars for these points
noxlims = ~(xlolims | xuplims)
Expand Down Expand Up @@ -3458,7 +3443,7 @@ def extract_err(err, data):
**eb_cap_style))

if yerr is not None:
lower, upper = extract_err(yerr, y)
lower, upper = extract_err('y', yerr, y)
# select points without upper/lower limits in y and
# draw normal errorbars for these points
noylims = ~(lolims | uplims)
Expand Down
8 changes: 1 addition & 7 deletions lib/matplotlib/backends/backend_nbagg.py
Original file line number Diff line number Diff line change
Expand Up @@ -239,13 +239,7 @@ def trigger_manager_draw(manager):
manager.show()

@staticmethod
def show(*args, block=None, **kwargs):
if args or kwargs:
cbook.warn_deprecated(
"3.1", message="Passing arguments to show(), other than "
"passing 'block' by keyword, is deprecated %(since)s, and "
"support for it will be removed %(removal)s.")

def show(block=None):
## TODO: something to do when keyword block==False ?
from matplotlib._pylab_helpers import Gcf

Expand Down
9 changes: 1 addition & 8 deletions lib/matplotlib/collections.py
Original file line number Diff line number Diff line change
Expand Up @@ -302,14 +302,7 @@ def draw(self, renderer):

if self._hatch:
gc.set_hatch(self._hatch)
try:
gc.set_hatch_color(self._hatch_color)
except AttributeError:
# if we end up with a GC that does not have this method
cbook.warn_deprecated(
"3.1", message="Your backend does not support setting the "
"hatch color; such backends will become unsupported in "
"Matplotlib 3.3.")
gc.set_hatch_color(self._hatch_color)

if self.get_sketch_params() is not None:
gc.set_sketch_params(*self.get_sketch_params())
Expand Down
16 changes: 5 additions & 11 deletions lib/matplotlib/colors.py
Original file line number Diff line number Diff line change
Expand Up @@ -198,17 +198,11 @@ def _to_rgba_no_colorcycle(c, alpha=None):
# This may turn c into a non-string, so we check again below.
c = _colors_full_map[c]
except KeyError:
try:
c = _colors_full_map[c.lower()]
except KeyError:
pass
else:
if len(orig_c) == 1:
cbook.warn_deprecated(
"3.1", message="Support for uppercase "
"single-letter colors is deprecated since Matplotlib "
"%(since)s and will be removed %(removal)s; please "
"use lowercase instead.")
if len(orig_c) != 1:
try:
c = _colors_full_map[c.lower()]
except KeyError:
pass
if isinstance(c, str):
# hex color in #rrggbb format.
match = re.match(r"\A#[a-fA-F0-9]{6}\Z", c)
Expand Down
Loading