Skip to content

Commit 84c1392

Browse files
Merge branch 'main' into 3d_plot_zoom
2 parents a607764 + 61fa334 commit 84c1392

File tree

27 files changed

+89
-76
lines changed

27 files changed

+89
-76
lines changed

.github/workflows/tests.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ on:
99

1010
env:
1111
NO_AT_BRIDGE: 1 # Necessary for GTK3 interactive test.
12+
NPY_DISABLE_CPU_FEATURES: "AVX512F,AVX512CD,AVX512VL,AVX512BW,AVX512DQ,AVX512_SKX"
1213
OPENBLAS_NUM_THREADS: 1
1314
PYTHONFAULTHANDLER: 1
1415

azure-pipelines.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,7 @@ stages:
129129
displayName: 'print env'
130130

131131
- bash: |
132+
export NPY_DISABLE_CPU_FEATURES="AVX512F,AVX512CD,AVX512VL,AVX512BW,AVX512DQ,AVX512_SKX"
132133
PYTHONFAULTHANDLER=1 python -m pytest --junitxml=junit/test-results.xml -raR --maxfail=50 --timeout=300 --durations=25 --cov-report= --cov=lib -n 2 ||
133134
[[ "$PYTHON_VERSION" = 'Pre' ]]
134135
displayName: 'pytest'
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
3D contourf polygons placed between levels
22
------------------------------------------
3-
The polygons used in a 3D `~mpl_toolkits.mplot3d.Axes3D.contourf` plot are
3+
The polygons used in a 3D `~.Axes3D.contourf` plot are
44
now placed halfway between the contour levels, as each polygon represents the
55
location of values that lie between two levels.

doc/api/prev_api_changes/api_changes_3.5.0/behaviour.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -235,7 +235,7 @@ yet parsed, but this is a prerequisite for implementing subsetting.
235235
3D contourf polygons placed between levels
236236
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
237237

238-
The polygons used in a 3D `~mpl_toolkits.mplot3d.Axes3D.contourf` plot are now
238+
The polygons used in a 3D `~.Axes3D.contourf` plot are now
239239
placed halfway between the contour levels, as each polygon represents the
240240
location of values that lie between two levels.
241241

doc/index.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ Learning resources
5656
How-tos
5757
^^^^^^^
5858
- :doc:`Example gallery <gallery/index>`
59-
- :doc:`Matplotlib FAQ <faq/index>`
59+
- :doc:`Matplotlib FAQ <users/faq/index>`
6060

6161
---
6262

doc/users/explain/interactive.rst

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,15 +28,15 @@ that include interactive tools, a toolbar, a tool-tip, and
2828
:ref:`key bindings <key-event-handling>`:
2929

3030
`.pyplot.figure`
31-
Creates a new empty `.figure.Figure` or selects an existing figure
31+
Creates a new empty `.Figure` or selects an existing figure
3232

3333
`.pyplot.subplots`
34-
Creates a new `.figure.Figure` and fills it with a grid of `.axes.Axes`
34+
Creates a new `.Figure` and fills it with a grid of `~.axes.Axes`
3535

3636
`.pyplot` has a notion of "The Current Figure" which can be accessed
3737
through `.pyplot.gcf` and a notion of "The Current Axes" accessed
3838
through `.pyplot.gca`. Almost all of the functions in `.pyplot` pass
39-
through the current `.Figure` / `.axes.Axes` (or create one) as
39+
through the current `.Figure` / `~.axes.Axes` (or create one) as
4040
appropriate.
4141

4242
Matplotlib keeps a reference to all of the open figures
@@ -184,7 +184,7 @@ the GUI main loop in some other way.
184184

185185
.. warning::
186186

187-
Using `.figure.Figure.show` it is possible to display a figure on
187+
Using `.Figure.show` it is possible to display a figure on
188188
the screen without starting the event loop and without being in
189189
interactive mode. This may work (depending on the GUI toolkit) but
190190
will likely result in a non-responsive figure.

doc/users/explain/interactive_guide.rst

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -213,7 +213,7 @@ Blocking functions
213213
------------------
214214

215215
If you only need to collect points in an Axes you can use
216-
`.figure.Figure.ginput` or more generally the tools from
216+
`.Figure.ginput` or more generally the tools from
217217
`.blocking_input` the tools will take care of starting and stopping
218218
the event loop for you. However if you have written some custom event
219219
handling or are using `.widgets` you will need to manually run the GUI
@@ -315,7 +315,7 @@ Artists (as of Matplotlib 1.5) have a **stale** attribute which is
315315
`True` if the internal state of the artist has changed since the last
316316
time it was rendered. By default the stale state is propagated up to
317317
the Artists parents in the draw tree, e.g., if the color of a `.Line2D`
318-
instance is changed, the `.axes.Axes` and `.figure.Figure` that
318+
instance is changed, the `~.axes.Axes` and `.Figure` that
319319
contain it will also be marked as "stale". Thus, ``fig.stale`` will
320320
report if any artist in the figure has been modified and is out of sync
321321
with what is displayed on the screen. This is intended to be used to
@@ -332,11 +332,11 @@ which by default is set to a function that forwards the stale state to
332332
the artist's parent. If you wish to suppress a given artist from propagating
333333
set this attribute to None.
334334

335-
`.figure.Figure` instances do not have a containing artist and their
335+
`.Figure` instances do not have a containing artist and their
336336
default callback is `None`. If you call `.pyplot.ion` and are not in
337337
``IPython`` we will install a callback to invoke
338338
`~.backend_bases.FigureCanvasBase.draw_idle` whenever the
339-
`.figure.Figure` becomes stale. In ``IPython`` we use the
339+
`.Figure` becomes stale. In ``IPython`` we use the
340340
``'post_execute'`` hook to invoke
341341
`~.backend_bases.FigureCanvasBase.draw_idle` on any stale figures
342342
after having executed the user's input, but before returning the prompt

doc/users/prev_whats_new/whats_new_1.4.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -242,7 +242,7 @@ Simple quiver plot for mplot3d toolkit
242242
A team of students in an *Engineering Large Software Systems* course, taught
243243
by Prof. Anya Tafliovich at the University of Toronto, implemented a simple
244244
version of a quiver plot in 3D space for the mplot3d toolkit as one of their
245-
term project. This feature is documented in :func:`~mpl_toolkits.mplot3d.Axes3D.quiver`.
245+
term project. This feature is documented in `~.Axes3D.quiver`.
246246
The team members are: Ryan Steve D'Souza, Victor B, xbtsw, Yang Wang, David,
247247
Caradec Bisesar and Vlad Vassilovski.
248248

doc/users/prev_whats_new/whats_new_1.5.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -340,7 +340,7 @@ Added a :mod:`.legend_handler` for :class:`~matplotlib.collections.PolyCollectio
340340
Support for alternate pivots in mplot3d quiver plot
341341
```````````````````````````````````````````````````
342342

343-
Added a :code:`pivot` kwarg to :func:`~mpl_toolkits.mplot3d.Axes3D.quiver`
343+
Added a :code:`pivot` kwarg to `~.Axes3D.quiver`
344344
that controls the pivot point around which the quiver line rotates. This also
345345
determines the placement of the arrow head along the quiver line.
346346

doc/users/resources/index.rst

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,3 +77,7 @@ Tutorials
7777
* `Anatomy of Matplotlib - IPython Notebooks
7878
<https://github.com/WeatherGod/AnatomyOfMatplotlib>`_
7979
by Benjamin Root
80+
81+
* `Beyond the Basics: Data Visualization in Python
82+
<https://github.com/stefmolin/python-data-viz-workshop>`_
83+
by Stefanie Molin

examples/color/colorbar_basics.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@
33
Colorbar
44
========
55
6-
Use `~.figure.Figure.colorbar` by specifying the mappable object (here
7-
the `~.matplotlib.image.AxesImage` returned by `~.axes.Axes.imshow`)
6+
Use `~.Figure.colorbar` by specifying the mappable object (here
7+
the `.AxesImage` returned by `~.axes.Axes.imshow`)
88
and the axes to attach the colorbar to.
99
"""
1010

examples/subplots_axes_and_figures/demo_tight_layout.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,8 @@
33
Resizing axes with tight layout
44
===============================
55
6-
`~.figure.Figure.tight_layout` attempts to resize subplots in
7-
a figure so that there are no overlaps between axes objects and labels
8-
on the axes.
6+
`~.Figure.tight_layout` attempts to resize subplots in a figure so that there
7+
are no overlaps between axes objects and labels on the axes.
98
109
See :doc:`/tutorials/intermediate/tight_layout_guide` for more details and
1110
:doc:`/tutorials/intermediate/constrainedlayout_guide` for an alternative.

examples/subplots_axes_and_figures/gridspec_nested.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
set the position for a nested grid of subplots.
88
99
Note that the same functionality can be achieved more directly with
10-
`~.figure.FigureBase.subfigures`; see
10+
`~.FigureBase.subfigures`; see
1111
:doc:`/gallery/subplots_axes_and_figures/subfigures`.
1212
1313
"""

lib/matplotlib/_enums.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -148,9 +148,9 @@ class CapStyle(str, _AutoStringNameEnum):
148148
CapStyle.demo()
149149
150150
"""
151-
butt = 'butt'
152-
projecting = 'projecting'
153-
round = 'round'
151+
butt = auto()
152+
projecting = auto()
153+
round = auto()
154154

155155
@staticmethod
156156
def demo():

lib/matplotlib/colorbar.py

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1410,10 +1410,13 @@ def make_axes(parents, location=None, orientation=None, fraction=0.15,
14101410
anchor = kwargs.pop('anchor', loc_settings['anchor'])
14111411
panchor = kwargs.pop('panchor', loc_settings['panchor'])
14121412
aspect0 = aspect
1413-
# turn parents into a list if it is not already. We do this w/ np
1414-
# because `plt.subplots` can return an ndarray and is natural to
1415-
# pass to `colorbar`.
1416-
parents = np.atleast_1d(parents).ravel()
1413+
# turn parents into a list if it is not already. Note we cannot
1414+
# use .flatten or .ravel as these copy the references rather than
1415+
# reuse them, leading to a memory leak
1416+
if isinstance(parents, np.ndarray):
1417+
parents = list(parents.flat)
1418+
elif not isinstance(parents, list):
1419+
parents = [parents]
14171420
fig = parents[0].get_figure()
14181421

14191422
pad0 = 0.05 if fig.get_constrained_layout() else loc_settings['pad']
@@ -1461,8 +1464,8 @@ def make_axes(parents, location=None, orientation=None, fraction=0.15,
14611464
# tell the parent it has a colorbar
14621465
a._colorbars += [cax]
14631466
cax._colorbar_info = dict(
1464-
location=location,
14651467
parents=parents,
1468+
location=location,
14661469
shrink=shrink,
14671470
anchor=anchor,
14681471
panchor=panchor,
@@ -1586,6 +1589,7 @@ def make_axes_gridspec(parent, *, location=None, orientation=None,
15861589
fraction=fraction,
15871590
aspect=aspect0,
15881591
pad=pad)
1592+
15891593
return cax, kwargs
15901594

15911595

lib/matplotlib/figure.py

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -180,8 +180,8 @@ def update(self, left=None, bottom=None, right=None, top=None,
180180

181181
class FigureBase(Artist):
182182
"""
183-
Base class for `.figure.Figure` and `.figure.SubFigure` containing the
184-
methods that add artists to the figure or subfigure, create Axes, etc.
183+
Base class for `.Figure` and `.SubFigure` containing the methods that add
184+
artists to the figure or subfigure, create Axes, etc.
185185
"""
186186
def __init__(self, **kwargs):
187187
super().__init__()
@@ -1453,8 +1453,7 @@ def subfigures(self, nrows=1, ncols=1, squeeze=True,
14531453

14541454
def add_subfigure(self, subplotspec, **kwargs):
14551455
"""
1456-
Add a `~.figure.SubFigure` to the figure as part of a subplot
1457-
arrangement.
1456+
Add a `.SubFigure` to the figure as part of a subplot arrangement.
14581457
14591458
Parameters
14601459
----------
@@ -1464,12 +1463,12 @@ def add_subfigure(self, subplotspec, **kwargs):
14641463
14651464
Returns
14661465
-------
1467-
`.figure.SubFigure`
1466+
`.SubFigure`
14681467
14691468
Other Parameters
14701469
----------------
14711470
**kwargs
1472-
Are passed to the `~.figure.SubFigure` object.
1471+
Are passed to the `.SubFigure` object.
14731472
14741473
See Also
14751474
--------
@@ -1964,7 +1963,7 @@ def __init__(self, parent, subplotspec, *,
19641963
"""
19651964
Parameters
19661965
----------
1967-
parent : `.figure.Figure` or `.figure.SubFigure`
1966+
parent : `.Figure` or `.SubFigure`
19681967
Figure or subfigure that contains the SubFigure. SubFigures
19691968
can be nested.
19701969

lib/matplotlib/gridspec.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -344,7 +344,7 @@ def __init__(self, nrows, ncols, figure=None,
344344
nrows, ncols : int
345345
The number of rows and columns of the grid.
346346
347-
figure : `~.figure.Figure`, optional
347+
figure : `.Figure`, optional
348348
Only used for constrained layout to create a proper layoutgrid.
349349
350350
left, right, top, bottom : float, optional

lib/matplotlib/image.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1748,7 +1748,7 @@ def thumbnail(infile, thumbfile, scale=0.1, interpolation='bilinear',
17481748
17491749
Returns
17501750
-------
1751-
`~.figure.Figure`
1751+
`.Figure`
17521752
The figure instance containing the thumbnail.
17531753
"""
17541754

lib/matplotlib/pyplot.py

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1363,13 +1363,12 @@ def subplots(nrows=1, ncols=1, *, sharex=False, sharey=False, squeeze=True,
13631363
13641364
Returns
13651365
-------
1366-
fig : `~.figure.Figure`
1366+
fig : `.Figure`
13671367
1368-
ax : `.axes.Axes` or array of Axes
1369-
*ax* can be either a single `~matplotlib.axes.Axes` object or an
1370-
array of Axes objects if more than one subplot was created. The
1371-
dimensions of the resulting array can be controlled with the squeeze
1372-
keyword, see above.
1368+
ax : `~.axes.Axes` or array of Axes
1369+
*ax* can be either a single `~.axes.Axes` object, or an array of Axes
1370+
objects if more than one subplot was created. The dimensions of the
1371+
resulting array can be controlled with the squeeze keyword, see above.
13731372
13741373
Typical idioms for handling the return value are::
13751374
@@ -1516,7 +1515,7 @@ def subplot_mosaic(mosaic, *, sharex=False, sharey=False,
15161515
15171516
Returns
15181517
-------
1519-
fig : `~.figure.Figure`
1518+
fig : `.Figure`
15201519
The new figure
15211520
15221521
dict[label, Axes]

lib/matplotlib/tests/test_backend_tk.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,8 @@ def test_func():
3636
try:
3737
proc = subprocess.run(
3838
[sys.executable, "-c", f"{source}\n{func.__name__}()"],
39-
env={**os.environ, "MPLBACKEND": "TkAgg"},
39+
env={**os.environ, "MPLBACKEND": "TkAgg",
40+
"NPY_DISABLE_CPU_FEATURES": ""},
4041
timeout=_test_timeout,
4142
stdout=subprocess.PIPE,
4243
stderr=subprocess.PIPE,

lib/matplotlib/tests/test_sphinxext.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,8 @@ def test_tinypages(tmpdir):
2828
# coverage anyways); hide them using GCOV_ERROR_FILE.
2929
proc = Popen(
3030
cmd, stdout=PIPE, stderr=PIPE, universal_newlines=True,
31-
env={**os.environ, "MPLBACKEND": "", "GCOV_ERROR_FILE": os.devnull})
31+
env={**os.environ, "MPLBACKEND": "", "GCOV_ERROR_FILE": os.devnull,
32+
"NPY_DISABLE_CPU_FEATURES": ""})
3233
out, err = proc.communicate()
3334

3435
# Build the pages with warnings turned into errors
@@ -128,7 +129,8 @@ def build_sphinx_html(source_dir, doctree_dir, html_dir, extra_args=None):
128129
cmd = [sys.executable, '-msphinx', '-W', '-b', 'html',
129130
'-d', str(doctree_dir), str(source_dir), str(html_dir), *extra_args]
130131
proc = Popen(cmd, stdout=PIPE, stderr=PIPE, universal_newlines=True,
131-
env={**os.environ, "MPLBACKEND": ""})
132+
env={**os.environ, "MPLBACKEND": "",
133+
"NPY_DISABLE_CPU_FEATURES": ""})
132134
out, err = proc.communicate()
133135

134136
assert proc.returncode == 0, \

lib/matplotlib/tests/test_ticker.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -500,6 +500,13 @@ class TestScalarFormatter:
500500
[12.3, "12.300"],
501501
]
502502

503+
format_data = [
504+
(.1, "1e-1"),
505+
(.11, "1.1e-1"),
506+
(1e8, "1e8"),
507+
(1.1e8, "1.1e8"),
508+
]
509+
503510
@pytest.mark.parametrize('unicode_minus, result',
504511
[(True, "\N{MINUS SIGN}1"), (False, "-1")])
505512
def test_unicode_minus(self, unicode_minus, result):
@@ -561,6 +568,12 @@ def test_scilimits(self, sci_type, scilimits, lim, orderOfMag, fewticks):
561568
tmp_form.set_locs(ax.yaxis.get_majorticklocs())
562569
assert orderOfMag == tmp_form.orderOfMagnitude
563570

571+
@pytest.mark.parametrize('value, expected', format_data)
572+
def test_format_data(self, value, expected):
573+
mpl.rcParams['axes.unicode_minus'] = False
574+
sf = mticker.ScalarFormatter()
575+
assert sf.format_data(value) == expected
576+
564577
@pytest.mark.parametrize('data, expected', cursor_data)
565578
def test_cursor_precision(self, data, expected):
566579
fig, ax = plt.subplots()

lib/matplotlib/ticker.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -664,7 +664,7 @@ def format_data(self, value):
664664
s = round(value / 10**e, 10)
665665
exponent = self._format_maybe_minus_and_locale("%d", e)
666666
significand = self._format_maybe_minus_and_locale(
667-
"%d" if s % 1 == 0 else "%1.10f", s)
667+
"%d" if s % 1 == 0 else "%1.10g", s)
668668
if e == 0:
669669
return significand
670670
elif self._useMathText or self._usetex:

tutorials/intermediate/arranging_axes.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
"""
2-
=====================================
2+
===================================
33
Arranging multiple Axes in a Figure
4-
=====================================
4+
===================================
55
66
Often more than one Axes is wanted on a figure at a time, usually
77
organized into a regular grid. Matplotlib has a variety of tools for
@@ -37,7 +37,7 @@
3737
`.Figure.subplot_mosaic` and :doc:`/tutorials/provisional/mosaic`.
3838
3939
Sometimes it is natural to have more than one distinct group of Axes grids,
40-
in which case Matplotlib has the concept of `~.figure.SubFigure`:
40+
in which case Matplotlib has the concept of `.SubFigure`:
4141
4242
`~matplotlib.figure.SubFigure`
4343
A virtual figure within a figure.

0 commit comments

Comments
 (0)