diff --git a/doc/api/next_api_changes/deprecations.rst b/doc/api/next_api_changes/deprecations.rst index 9e1a6862d872..c66f26cca69c 100644 --- a/doc/api/next_api_changes/deprecations.rst +++ b/doc/api/next_api_changes/deprecations.rst @@ -284,3 +284,7 @@ is deprecated, set the offset to 0 instead. ``RendererCairo.fontweights``, ``RendererCairo.fontangles`` ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ... are deprecated. + +``autofmt_xdate(which=None)`` +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +This is deprecated, use its more explicit synonym, ``which="major"``, instead. diff --git a/lib/matplotlib/figure.py b/lib/matplotlib/figure.py index 2f9d2142b789..9bd9a35a5847 100644 --- a/lib/matplotlib/figure.py +++ b/lib/matplotlib/figure.py @@ -574,7 +574,8 @@ def get_constrained_layout_pads(self, relative=False): return w_pad, h_pad, wspace, hspace - def autofmt_xdate(self, bottom=0.2, rotation=30, ha='right', which=None): + def autofmt_xdate( + self, bottom=0.2, rotation=30, ha='right', which='major'): """ Date ticklabels often overlap, so it is useful to rotate them and right align them. Also, a common use case is a number of @@ -586,18 +587,19 @@ def autofmt_xdate(self, bottom=0.2, rotation=30, ha='right', which=None): Parameters ---------- bottom : scalar - The bottom of the subplots for :meth:`subplots_adjust`. - + The bottom of the subplots for `subplots_adjust`. rotation : angle in degrees The rotation of the xtick labels. - ha : str The horizontal alignment of the xticklabels. - - which : {None, 'major', 'minor', 'both'} - Selects which ticklabels to rotate. Default is None which works - the same as major. + which : {'major', 'minor', 'both'}, default: 'major' + Selects which ticklabels to rotate. """ + if which is None: + cbook.warn_deprecated( + "3.3", message="Support for passing which=None to mean " + "which='major' is deprecated since %(since)s and will be " + "removed %(removal)s.") allsubplots = all(hasattr(ax, 'is_last_row') for ax in self.axes) if len(self.axes) == 1: for label in self.axes[0].get_xticklabels(which=which): diff --git a/lib/matplotlib/tests/test_figure.py b/lib/matplotlib/tests/test_figure.py index 3586f7457f59..f1a8bc15cd6d 100644 --- a/lib/matplotlib/tests/test_figure.py +++ b/lib/matplotlib/tests/test_figure.py @@ -2,6 +2,10 @@ from pathlib import Path import platform import warnings +try: + from contextlib import nullcontext +except ImportError: + from contextlib import ExitStack as nullcontext # Py3.6 import matplotlib as mpl from matplotlib import rcParams @@ -318,7 +322,9 @@ def test_autofmt_xdate(which): 'FixedFormatter should only be used together with FixedLocator') ax.xaxis.set_minor_formatter(FixedFormatter(minors)) - fig.autofmt_xdate(0.2, angle, 'right', which) + with (pytest.warns(mpl.MatplotlibDeprecationWarning) if which is None else + nullcontext()): + fig.autofmt_xdate(0.2, angle, 'right', which) if which in ('both', 'major', None): for label in fig.axes[0].get_xticklabels(False, 'major'): pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy