Skip to content

Commit c4fb35e

Browse files
authored
Merge branch 'matplotlib:main' into shuffleFix
2 parents 0427513 + af39f1e commit c4fb35e

File tree

18 files changed

+151
-248
lines changed

18 files changed

+151
-248
lines changed

.github/workflows/tests.yml

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -240,9 +240,13 @@ jobs:
240240
241241
cat mplsetup.cfg
242242
243-
# All dependencies must have been pre-installed, so that the minver
244-
# constraints are held.
245-
python -m pip install --no-deps -ve .
243+
if [[ "${{ matrix.name-suffix }}" == '(Minimum Versions)' ]]; then
244+
# Minimum versions run does not use build isolation so that it
245+
# builds against the pre-installed minver dependencies.
246+
python -m pip install --no-deps --no-build-isolation -ve .
247+
else
248+
python -m pip install --no-deps -ve .
249+
fi
246250
247251
if [[ "${{ runner.os }}" != 'macOS' ]]; then
248252
unset CPPFLAGS

doc/api/animation_api.rst

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,11 @@ this hopefully minimalist example gives a sense of how ``init_func``
9797
and ``func`` are used inside of `FuncAnimation` and the theory of how
9898
'blitting' works.
9999

100+
.. note::
101+
102+
The zorder of artists is not taken into account when 'blitting'
103+
because the 'blitted' artists are always drawn on top.
104+
100105
The expected signature on ``func`` and ``init_func`` is very simple to
101106
keep `FuncAnimation` out of your book keeping and plotting logic, but
102107
this means that the callable objects you pass in must know what
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
``contour.ClabelText`` and ``ContourLabeler.set_label_props``
2+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
3+
... are deprecated.
4+
5+
Use ``Text(..., transform_rotates_text=True)`` as a replacement for
6+
``contour.ClabelText(...)`` and ``text.set(text=text, color=color,
7+
fontproperties=labeler.labelFontProps, clip_box=labeler.axes.bbox)`` as a
8+
replacement for the ``ContourLabeler.set_label_props(label, text, color)``.
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
``epoch2num`` and ``num2epoch`` are removed
2+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
3+
4+
These methods convert from unix timestamps to matplotlib floats, but are not
5+
used internally to Matplotlib, and should not be needed by end users. To
6+
convert a unix timestamp to datetime, simply use
7+
`datetime.datetime.utcfromtimestamp`, or to use NumPy `~numpy.datetime64`
8+
``dt = np.datetime64(e*1e6, 'us')``.
9+
10+
11+
Locator and Formatter wrapper methods
12+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
13+
14+
The ``set_view_interval``, ``set_data_interval`` and ``set_bounds`` methods of
15+
`.Locator`\s and `.Formatter`\s (and their common base class, TickHelper) are
16+
removed. Directly manipulate the view and data intervals on the underlying
17+
axis instead.

doc/api/prev_api_changes/api_changes_3.3.0/deprecations.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -545,8 +545,8 @@ experimental and may change in the future.
545545
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
546546
... is deprecated.
547547

548-
`.epoch2num` and `.num2epoch` are deprecated
549-
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
548+
``epoch2num`` and ``num2epoch`` are deprecated
549+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
550550
These are unused and can be easily reproduced by other date tools.
551551
`.get_epoch` will return Matplotlib's epoch.
552552

doc/api/prev_api_changes/api_changes_3.3.1.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ reverts the deprecation.
1515
Functions ``epoch2num`` and ``dates.julian2num`` use ``date.epoch`` rcParam
1616
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
1717

18-
Now `~.dates.epoch2num` and (undocumented) ``julian2num`` return floating point
18+
Now ``epoch2num`` and (undocumented) ``julian2num`` return floating point
1919
days since `~.dates.get_epoch` as set by :rc:`date.epoch`, instead of
2020
floating point days since the old epoch of "0000-12-31T00:00:00". If
2121
needed, you can translate from the new to old values as

doc/devel/coding_guide.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ When making a PR, pay attention to:
4545
on GitHub.
4646
* When updating your PR, instead of adding new commits to fix something, please
4747
consider amending your initial commit(s) to keep the history clean.
48-
You can achieve this using
48+
You can achieve this by using
4949

5050
.. code-block:: bash
5151

doc/devel/contributing.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -222,7 +222,7 @@ rules before submitting a pull request:
222222

223223
or your editor may provide integration with it. Note that Matplotlib
224224
intentionally does not use the black_ auto-formatter (1__), in particular due
225-
to its unability to understand the semantics of mathematical expressions
225+
to its inability to understand the semantics of mathematical expressions
226226
(2__, 3__).
227227

228228
.. _PEP8: https://www.python.org/dev/peps/pep-0008/

lib/matplotlib/axes/_secondary_axes.py

Lines changed: 23 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
import numbers
2+
13
import numpy as np
24

35
from matplotlib import _api, _docstring
@@ -17,7 +19,7 @@ def __init__(self, parent, orientation, location, functions, **kwargs):
1719
While there is no need for this to be private, it should really be
1820
called by those higher level functions.
1921
"""
20-
22+
_api.check_in_list(["x", "y"], orientation=orientation)
2123
self._functions = functions
2224
self._parent = parent
2325
self._orientation = orientation
@@ -28,7 +30,7 @@ def __init__(self, parent, orientation, location, functions, **kwargs):
2830
self._axis = self.xaxis
2931
self._locstrings = ['top', 'bottom']
3032
self._otherstrings = ['left', 'right']
31-
elif self._orientation == 'y':
33+
else: # 'y'
3234
super().__init__(self._parent.figure, [0, 1., 0.0001, 1], **kwargs)
3335
self._axis = self.yaxis
3436
self._locstrings = ['right', 'left']
@@ -40,11 +42,7 @@ def __init__(self, parent, orientation, location, functions, **kwargs):
4042
self.set_functions(functions)
4143

4244
# styling:
43-
if self._orientation == 'x':
44-
otheraxis = self.yaxis
45-
else:
46-
otheraxis = self.xaxis
47-
45+
otheraxis = self.yaxis if self._orientation == 'x' else self.xaxis
4846
otheraxis.set_major_locator(mticker.NullLocator())
4947
otheraxis.set_ticks_position('none')
5048

@@ -63,8 +61,8 @@ def set_alignment(self, align):
6361
6462
Parameters
6563
----------
66-
align : str
67-
either 'top' or 'bottom' for orientation='x' or
64+
align : {'top', 'bottom', 'left', 'right'}
65+
Either 'top' or 'bottom' for orientation='x' or
6866
'left' or 'right' for orientation='y' axis.
6967
"""
7068
_api.check_in_list(self._locstrings, align=align)
@@ -92,23 +90,22 @@ def set_location(self, location):
9290

9391
# This puts the rectangle into figure-relative coordinates.
9492
if isinstance(location, str):
95-
if location in ['top', 'right']:
96-
self._pos = 1.
97-
elif location in ['bottom', 'left']:
98-
self._pos = 0.
99-
else:
100-
raise ValueError(
101-
f"location must be {self._locstrings[0]!r}, "
102-
f"{self._locstrings[1]!r}, or a float, not {location!r}")
103-
else:
93+
_api.check_in_list(self._locstrings, location=location)
94+
self._pos = 1. if location in ('top', 'right') else 0.
95+
elif isinstance(location, numbers.Real):
10496
self._pos = location
97+
else:
98+
raise ValueError(
99+
f"location must be {self._locstrings[0]!r}, "
100+
f"{self._locstrings[1]!r}, or a float, not {location!r}")
101+
105102
self._loc = location
106103

107104
if self._orientation == 'x':
108105
# An x-secondary axes is like an inset axes from x = 0 to x = 1 and
109106
# from y = pos to y = pos + eps, in the parent's transAxes coords.
110107
bounds = [0, self._pos, 1., 1e-10]
111-
else:
108+
else: # 'y'
112109
bounds = [self._pos, 0, 1e-10, 1]
113110

114111
# this locator lets the axes move in the parent axes coordinates.
@@ -161,9 +158,7 @@ def set_functions(self, functions):
161158
'and the second being the inverse')
162159
self._set_scale()
163160

164-
# Should be changed to draw(self, renderer) once the deprecation of
165-
# renderer=None and of inframe expires.
166-
def draw(self, *args, **kwargs):
161+
def draw(self, renderer):
167162
"""
168163
Draw the secondary axes.
169164
@@ -175,7 +170,7 @@ def draw(self, *args, **kwargs):
175170
self._set_lims()
176171
# this sets the scale in case the parent has set its scale.
177172
self._set_scale()
178-
super().draw(*args, **kwargs)
173+
super().draw(renderer)
179174

180175
def _set_scale(self):
181176
"""
@@ -185,22 +180,18 @@ def _set_scale(self):
185180
if self._orientation == 'x':
186181
pscale = self._parent.xaxis.get_scale()
187182
set_scale = self.set_xscale
188-
if self._orientation == 'y':
183+
else: # 'y'
189184
pscale = self._parent.yaxis.get_scale()
190185
set_scale = self.set_yscale
191186
if pscale == self._parentscale:
192187
return
193188

194-
if pscale == 'log':
195-
defscale = 'functionlog'
196-
else:
197-
defscale = 'function'
198-
199189
if self._ticks_set:
200190
ticks = self._axis.get_ticklocs()
201191

202192
# need to invert the roles here for the ticks to line up.
203-
set_scale(defscale, functions=self._functions[::-1])
193+
set_scale('functionlog' if pscale == 'log' else 'function',
194+
functions=self._functions[::-1])
204195

205196
# OK, set_scale sets the locators, but if we've called
206197
# axsecond.set_ticks, we want to keep those.
@@ -218,7 +209,7 @@ def _set_lims(self):
218209
if self._orientation == 'x':
219210
lims = self._parent.get_xlim()
220211
set_lim = self.set_xlim
221-
if self._orientation == 'y':
212+
else: # 'y'
222213
lims = self._parent.get_ylim()
223214
set_lim = self.set_ylim
224215
order = lims[0] < lims[1]
@@ -249,7 +240,7 @@ def set_color(self, color):
249240
self.spines.bottom.set_color(color)
250241
self.spines.top.set_color(color)
251242
self.xaxis.label.set_color(color)
252-
else:
243+
else: # 'y'
253244
self.tick_params(axis='y', colors=color)
254245
self.spines.left.set_color(color)
255246
self.spines.right.set_color(color)

0 commit comments

Comments
 (0)