FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

Deprecate autofmt_xdate(which=None) to mean which="major". by anntzer · Pull Request #16636 · matplotlib/matplotlib · GitHub

Repository navigation

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension .py  (2) .rst  (1) All 2 file types selected
Viewed files
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Unified
Split
Hide whitespace
Diff view
Unified
Split
Hide whitespace
4 changes: 4 additions & 0 deletions doc/api/next_api_changes/deprecations.rst
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
Expand Up @@ -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.
18 changes: 10 additions & 8 deletions lib/matplotlib/figure.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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):
Expand Down
8 changes: 7 additions & 1 deletion lib/matplotlib/tests/test_figure.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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'):
Expand Down

Back | FazBrowse Home | New Git URL