Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 81f3a23

Browse files
Merge branch 'main' into 3d_plot_focal_length
2 parents e8a3f57 + 61fa334 commit 81f3a23

36 files changed

+143
-96
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.
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
``FigureCanvasBase.resize``
2+
~~~~~~~~~~~~~~~~~~~~~~~~~~~
3+
This method has no effect and is deprecated. Use ``FigureManagerBase.resize``
4+
instead.
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
``FigureCanvas`` without a ``required_interactive_framework`` attribute
2+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
3+
Support for such canvas classes is deprecated. Note that canvas classes which
4+
inherit from ``FigureCanvasBase`` always have such an attribute.

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/lines_bars_and_markers/broken_barh.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,15 +7,16 @@
77
"""
88
import matplotlib.pyplot as plt
99

10+
# Horizontal bar plot with gaps
1011
fig, ax = plt.subplots()
1112
ax.broken_barh([(110, 30), (150, 10)], (10, 9), facecolors='tab:blue')
1213
ax.broken_barh([(10, 50), (100, 20), (130, 10)], (20, 9),
1314
facecolors=('tab:orange', 'tab:green', 'tab:red'))
1415
ax.set_ylim(5, 35)
1516
ax.set_xlim(0, 200)
1617
ax.set_xlabel('seconds since start')
17-
ax.set_yticks([15, 25], labels=['Bill', 'Jim'])
18-
ax.grid(True)
18+
ax.set_yticks([15, 25], labels=['Bill', 'Jim']) # Modify y-axis tick labels
19+
ax.grid(True) # Make grid lines visible
1920
ax.annotate('race interrupted', (61, 25),
2021
xytext=(0.8, 0.9), textcoords='axes fraction',
2122
arrowprops=dict(facecolor='black', shrink=0.05),

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/axes/_axes.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -118,9 +118,9 @@ def set_title(self, label, fontdict=None, loc=None, pad=None, *, y=None,
118118
Which title to set.
119119
120120
y : float, default: :rc:`axes.titley`
121-
Vertical Axes loation for the title (1.0 is the top). If
122-
None (the default), y is determined automatically to avoid
123-
decorators on the Axes.
121+
Vertical Axes location for the title (1.0 is the top). If
122+
None (the default) and :rc:`axes.titley` is also None, y is
123+
determined automatically to avoid decorators on the Axes.
124124
125125
pad : float, default: :rc:`axes.titlepad`
126126
The offset of the title from the top of the Axes, in points.

lib/matplotlib/backend_bases.py

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1650,9 +1650,13 @@ def _fix_ipython_backend2gui(cls):
16501650
# In case we ever move the patch to IPython and remove these APIs,
16511651
# don't break on our side.
16521652
return
1653-
rif = getattr(cls, "required_interactive_framework", None)
1654-
backend2gui_rif = {"qt": "qt", "gtk3": "gtk3", "gtk4": "gtk4",
1655-
"wx": "wx", "macosx": "osx"}.get(rif)
1653+
backend2gui_rif = {
1654+
"qt": "qt",
1655+
"gtk3": "gtk3",
1656+
"gtk4": "gtk4",
1657+
"wx": "wx",
1658+
"macosx": "osx",
1659+
}.get(cls.required_interactive_framework)
16561660
if backend2gui_rif:
16571661
if _is_non_interactive_terminal_ipython(ip):
16581662
ip.enable_gui(backend2gui_rif)
@@ -1679,6 +1683,7 @@ def pick(self, mouseevent):
16791683
def blit(self, bbox=None):
16801684
"""Blit the canvas in bbox (default entire canvas)."""
16811685

1686+
@_api.deprecated("3.6", alternative="FigureManagerBase.resize")
16821687
def resize(self, w, h):
16831688
"""
16841689
UNUSED: Set the canvas size in pixels.

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: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -199,8 +199,13 @@ def findobj(o=None, match=None, include_self=True):
199199

200200

201201
def _get_required_interactive_framework(backend_mod):
202-
return getattr(
203-
backend_mod.FigureCanvas, "required_interactive_framework", None)
202+
if not hasattr(backend_mod.FigureCanvas, "required_interactive_framework"):
203+
_api.warn_deprecated(
204+
"3.6", name="Support for FigureCanvases without a "
205+
"required_interactive_framework attribute")
206+
return None
207+
# Inline this once the deprecation elapses.
208+
return backend_mod.FigureCanvas.required_interactive_framework
204209

205210

206211
def switch_backend(newbackend):
@@ -1358,13 +1363,12 @@ def subplots(nrows=1, ncols=1, *, sharex=False, sharey=False, squeeze=True,
13581363
13591364
Returns
13601365
-------
1361-
fig : `~.figure.Figure`
1366+
fig : `.Figure`
13621367
1363-
ax : `.axes.Axes` or array of Axes
1364-
*ax* can be either a single `~matplotlib.axes.Axes` object or an
1365-
array of Axes objects if more than one subplot was created. The
1366-
dimensions of the resulting array can be controlled with the squeeze
1367-
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.
13681372
13691373
Typical idioms for handling the return value are::
13701374
@@ -1511,7 +1515,7 @@ def subplot_mosaic(mosaic, *, sharex=False, sharey=False,
15111515
15121516
Returns
15131517
-------
1514-
fig : `~.figure.Figure`
1518+
fig : `.Figure`
15151519
The new figure
15161520
15171521
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,

0 commit comments

Comments
 (0)