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

Skip to content

Commit 3b600e5

Browse files
committed
Merge branch 'main' of https://github.com/matplotlib/matplotlib into main
2 parents 79189ce + 9905cf0 commit 3b600e5

22 files changed

+89
-63
lines changed

.github/workflows/nightlies.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,11 +54,12 @@ jobs:
5454
run: |
5555
python -m pip install --upgrade pip setuptools wheel
5656
# c.f. https://github.com/Anaconda-Platform/anaconda-client/issues/540
57-
python -m pip install git+https://github.com/Anaconda-Server/anaconda-client
57+
python -m pip install git+https://github.com/Anaconda-Server/anaconda-client@be1e14936a8e947da94d026c990715f0596d7043
5858
python -m pip list
5959
6060
- name: Upload wheels to Anaconda Cloud as nightlies
6161
run: |
6262
anaconda --token ${{ secrets.ANACONDA_ORG_UPLOAD_TOKEN }} upload \
6363
--user scipy-wheels-nightly \
64+
--skip-existing \
6465
dist/matplotlib-*.whl

azure-pipelines.yml

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -130,13 +130,17 @@ stages:
130130
displayName: 'Install dependencies with pip'
131131
132132
- bash: |
133-
python -m pip install -ve . ||
133+
# Due to https://github.com/pypa/setuptools/pull/2896
134+
SETUPTOOLS_USE_DISTUTILS=stdlib python -m pip install -ve . ||
134135
[[ "$PYTHON_VERSION" = 'Pre' ]]
135136
displayName: "Install self"
136137
137138
- script: env
138139
displayName: 'print env'
139140

141+
- script: pip list
142+
displayName: 'print pip'
143+
140144
- bash: |
141145
PYTHONFAULTHANDLER=1 python -m pytest --junitxml=junit/test-results.xml -raR --maxfail=50 --timeout=300 --durations=25 --cov-report= --cov=lib -n 2 ||
142146
[[ "$PYTHON_VERSION" = 'Pre' ]]

doc/devel/documenting_mpl.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -729,7 +729,7 @@ gets interpolated into the docstring.
729729
Note that this scheme does not work for decorating an Artist's ``__init__``, as
730730
the subclass and its properties are not defined yet at that point. Instead,
731731
``@_docstring.interpd`` can be used to decorate the class itself -- at that
732-
point, `.kwdoc` can list the properties and interpolate them into
732+
point, `.artist.kwdoc` can list the properties and interpolate them into
733733
``__init__.__doc__``.
734734

735735

doc/users/installing/index.rst

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,12 @@ as the package index to query:
9292

9393
.. code-block:: sh
9494
95-
python -m pip install --upgrade --index-url https://pypi.anaconda.org/scipy-wheels-nightly/simple matplotlib
95+
python -m pip install \
96+
--upgrade \
97+
--pre \
98+
--index-url https://pypi.anaconda.org/scipy-wheels-nightly/simple \
99+
--extra-index-url https://pypi.org/simple \
100+
matplotlib
96101
97102
======================
98103
Installing from source

examples/lines_bars_and_markers/csd_demo.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,5 +38,5 @@
3838
ax1.grid(True)
3939

4040
cxy, f = ax2.csd(s1, s2, 256, 1. / dt)
41-
ax2.set_ylabel('CSD (db)')
41+
ax2.set_ylabel('CSD (dB)')
4242
plt.show()

examples/mplot3d/projections.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,15 +16,15 @@
1616
1717
You can calculate focal length from a FOV via the equation:
1818
19-
.. mathmpl::
19+
.. math::
2020
21-
1 / \tan (FOV / 2)
21+
1 / \\tan (\\mathrm{FOV} / 2)
2222
2323
Or vice versa:
2424
25-
.. mathmpl::
25+
.. math::
2626
27-
FOV = 2 * \atan (1 / focal length)
27+
\\mathrm{FOV} = 2 \\arctan (1 / \\mathrm{focal length})
2828
2929
"""
3030

examples/scales/asinh_demo.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,13 +15,13 @@
1515
1616
.. math::
1717
18-
a \\rightarrow a + {\\cal O}(a^3)
18+
a \\rightarrow a + \\mathcal{O}(a^3)
1919
2020
but for larger values (i.e. :math:`|a| \\gg a_0`, this is asymptotically
2121
2222
.. math::
2323
24-
a \\rightarrow a_0 \\, {\\rm sgn}(a) \\ln |a| + {\\cal O}(1)
24+
a \\rightarrow a_0 \\, \\mathrm{sgn}(a) \\ln |a| + \\mathcal{O}(1)
2525
2626
As with the `symlog <.scale.SymmetricalLogScale>` scaling,
2727
this allows one to plot quantities

lib/matplotlib/_constrained_layout.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
import numpy as np
1919

2020
from matplotlib import _api, artist as martist
21-
from matplotlib.backend_bases import _get_renderer
21+
from matplotlib._tight_layout import get_renderer
2222
import matplotlib.transforms as mtransforms
2323
import matplotlib._layoutgrid as mlayoutgrid
2424

@@ -92,7 +92,7 @@ def do_constrained_layout(fig, h_pad, w_pad,
9292
layoutgrid : private debugging structure
9393
"""
9494

95-
renderer = _get_renderer(fig)
95+
renderer = get_renderer(fig)
9696
# make layoutgrid tree...
9797
layoutgrids = make_layoutgrids(fig, None)
9898
if not layoutgrids['hasgrids']:

lib/matplotlib/animation.py

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
# * Can blit be enabled for movies?
1818
# * Need to consider event sources to allow clicking through multiple figures
1919

20+
2021
import abc
2122
import base64
2223
import contextlib
@@ -468,14 +469,15 @@ def grab_frame(self, **savefig_kwargs):
468469
def finish(self):
469470
# Call run here now that all frame grabbing is done. All temp files
470471
# are available to be assembled.
471-
self._run()
472-
super().finish() # Will call clean-up
473-
474-
def _cleanup(self): # Inline to finish() once cleanup() is removed.
475-
super()._cleanup()
476-
if self._tmpdir:
477-
_log.debug('MovieWriter: clearing temporary path=%s', self._tmpdir)
478-
self._tmpdir.cleanup()
472+
try:
473+
self._run()
474+
super().finish()
475+
finally:
476+
if self._tmpdir:
477+
_log.debug(
478+
'MovieWriter: clearing temporary path=%s', self._tmpdir
479+
)
480+
self._tmpdir.cleanup()
479481

480482

481483
@writers.register('pillow')

lib/matplotlib/axes/_axes.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2948,9 +2948,7 @@ def pie(self, x, explode=None, labels=None, colors=None,
29482948
Plot a pie chart.
29492949
29502950
Make a pie chart of array *x*. The fractional area of each wedge is
2951-
given by ``x/sum(x)``. If ``sum(x) < 1``, then the values of *x* give
2952-
the fractional area directly and the array will not be normalized. The
2953-
resulting pie will have an empty wedge of size ``1 - sum(x)``.
2951+
given by ``x/sum(x)``.
29542952
29552953
The wedges are plotted counterclockwise, by default starting from the
29562954
x-axis.

lib/matplotlib/backend_managers.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -206,9 +206,11 @@ def remove_tool(self, name):
206206
"""
207207

208208
tool = self.get_tool(name)
209-
_api.deprecate_method_override(
209+
destroy = _api.deprecate_method_override(
210210
backend_tools.ToolBase.destroy, tool, since="3.6",
211-
alternative="tool_removed_event")()
211+
alternative="tool_removed_event")
212+
if destroy is not None:
213+
destroy()
212214

213215
# If it's a toggle tool and toggled, untoggle
214216
if getattr(tool, 'toggled', False):

lib/matplotlib/backends/_backend_gtk.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -295,8 +295,7 @@ def remove_rubberband(self):
295295

296296
class ConfigureSubplotsGTK(backend_tools.ConfigureSubplotsBase):
297297
def trigger(self, *args):
298-
_NavigationToolbar2GTK.configure_subplots(
299-
self._make_classic_style_pseudo_toolbar(), None)
298+
_NavigationToolbar2GTK.configure_subplots(self, None)
300299

301300

302301
class _BackendGTK(_Backend):

lib/matplotlib/backends/_backend_tk.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -934,8 +934,7 @@ def trigger(self, *args):
934934
@backend_tools._register_tool_class(FigureCanvasTk)
935935
class ConfigureSubplotsTk(backend_tools.ConfigureSubplotsBase):
936936
def trigger(self, *args):
937-
NavigationToolbar2Tk.configure_subplots(
938-
self._make_classic_style_pseudo_toolbar())
937+
NavigationToolbar2Tk.configure_subplots(self)
939938

940939

941940
@backend_tools._register_tool_class(FigureCanvasTk)

lib/matplotlib/backends/backend_pdf.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1700,8 +1700,13 @@ def _writeImg(self, data, id, smask=None):
17001700
# Convert to indexed color if there are 256 colors or fewer
17011701
# This can significantly reduce the file size
17021702
num_colors = len(img_colors)
1703-
img = img.convert(mode='P', dither=Image.NONE,
1704-
palette=Image.ADAPTIVE, colors=num_colors)
1703+
# These constants were converted to IntEnums and deprecated in
1704+
# Pillow 9.2
1705+
dither = getattr(Image, 'Dither', Image).NONE
1706+
pmode = getattr(Image, 'Palette', Image).ADAPTIVE
1707+
img = img.convert(
1708+
mode='P', dither=dither, palette=pmode, colors=num_colors
1709+
)
17051710
png_data, bit_depth, palette = self._writePng(img)
17061711
if bit_depth is None or palette is None:
17071712
raise RuntimeError("invalid PNG header")

lib/matplotlib/backends/backend_qt.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -985,9 +985,12 @@ def set_message(self, s):
985985

986986
@backend_tools._register_tool_class(FigureCanvasQT)
987987
class ConfigureSubplotsQt(backend_tools.ConfigureSubplotsBase):
988+
def __init__(self, *args, **kwargs):
989+
super().__init__(*args, **kwargs)
990+
self._subplot_dialog = None
991+
988992
def trigger(self, *args):
989-
NavigationToolbar2QT.configure_subplots(
990-
self._make_classic_style_pseudo_toolbar())
993+
NavigationToolbar2QT.configure_subplots(self)
991994

992995

993996
@backend_tools._register_tool_class(FigureCanvasQT)

lib/matplotlib/backends/backend_wx.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1242,8 +1242,7 @@ def set_message(self, s):
12421242
@backend_tools._register_tool_class(_FigureCanvasWxBase)
12431243
class ConfigureSubplotsWx(backend_tools.ConfigureSubplotsBase):
12441244
def trigger(self, *args):
1245-
NavigationToolbar2Wx.configure_subplots(
1246-
self._make_classic_style_pseudo_toolbar())
1245+
NavigationToolbar2Wx.configure_subplots(self)
12471246

12481247

12491248
@backend_tools._register_tool_class(_FigureCanvasWxBase)

lib/matplotlib/colorbar.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1617,7 +1617,7 @@ def make_axes_gridspec(parent, *, location=None, orientation=None,
16171617
aspect = 1 / aspect
16181618

16191619
parent.set_subplotspec(ss_main)
1620-
parent.set_anchor(panchor)
1620+
parent.set_anchor(loc_settings["panchor"])
16211621

16221622
fig = parent.get_figure()
16231623
cax = fig.add_subplot(ss_cb, label="<colorbar>")

lib/matplotlib/layout_engine.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,8 @@
2222
from matplotlib._constrained_layout import do_constrained_layout
2323
from matplotlib._tight_layout import (get_subplotspec_list,
2424
get_tight_layout_figure)
25-
from matplotlib.backend_bases import _get_renderer
25+
# from matplotlib.backend_bases import _get_renderer
26+
from matplotlib._tight_layout import get_renderer
2627

2728

2829
class LayoutEngine:
@@ -153,7 +154,7 @@ def execute(self, fig):
153154
_api.warn_external("This figure includes Axes that are not "
154155
"compatible with tight_layout, so results "
155156
"might be incorrect.")
156-
renderer = _get_renderer(fig)
157+
renderer = get_renderer(fig)
157158
with getattr(renderer, "_draw_disabled", nullcontext)():
158159
kwargs = get_tight_layout_figure(
159160
fig, fig.axes, subplotspec_list, renderer,

lib/matplotlib/mlab.py

Lines changed: 21 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@
6060

6161
def window_hanning(x):
6262
"""
63-
Return x times the hanning window of len(x).
63+
Return *x* times the Hanning (or Hann) window of len(*x*).
6464
6565
See Also
6666
--------
@@ -71,7 +71,7 @@ def window_hanning(x):
7171

7272
def window_none(x):
7373
"""
74-
No window function; simply return x.
74+
No window function; simply return *x*.
7575
7676
See Also
7777
--------
@@ -82,7 +82,7 @@ def window_none(x):
8282

8383
def detrend(x, key=None, axis=None):
8484
"""
85-
Return x with its trend removed.
85+
Return *x* with its trend removed.
8686
8787
Parameters
8888
----------
@@ -131,7 +131,7 @@ def detrend(x, key=None, axis=None):
131131

132132
def detrend_mean(x, axis=None):
133133
"""
134-
Return x minus the mean(x).
134+
Return *x* minus the mean(*x*).
135135
136136
Parameters
137137
----------
@@ -140,7 +140,7 @@ def detrend_mean(x, axis=None):
140140
Can have any dimensionality
141141
142142
axis : int
143-
The axis along which to take the mean. See numpy.mean for a
143+
The axis along which to take the mean. See `numpy.mean` for a
144144
description of this argument.
145145
146146
See Also
@@ -159,7 +159,7 @@ def detrend_mean(x, axis=None):
159159

160160
def detrend_none(x, axis=None):
161161
"""
162-
Return x: no detrending.
162+
Return *x*: no detrending.
163163
164164
Parameters
165165
----------
@@ -181,7 +181,7 @@ def detrend_none(x, axis=None):
181181

182182
def detrend_linear(y):
183183
"""
184-
Return x minus best fit line; 'linear' detrending.
184+
Return *x* minus best fit line; 'linear' detrending.
185185
186186
Parameters
187187
----------
@@ -216,7 +216,7 @@ def detrend_linear(y):
216216
@_api.deprecated("3.6")
217217
def stride_windows(x, n, noverlap=None, axis=0):
218218
"""
219-
Get all windows of x with length n as a single array,
219+
Get all windows of *x* with length *n* as a single array,
220220
using strides to avoid data duplication.
221221
222222
.. warning::
@@ -497,8 +497,8 @@ def _single_spectrum_helper(
497497
the FFT. While not increasing the actual resolution of the spectrum (the
498498
minimum distance between resolvable peaks), this can give more points in
499499
the plot, allowing for more detail. This corresponds to the *n* parameter
500-
in the call to fft(). The default is None, which sets *pad_to* equal to
501-
the length of the input signal (i.e. no padding).""",
500+
in the call to `~numpy.fft.fft`. The default is None, which sets *pad_to*
501+
equal to the length of the input signal (i.e. no padding).""",
502502

503503
PSD="""\
504504
pad_to : int, optional
@@ -507,8 +507,8 @@ def _single_spectrum_helper(
507507
of data points used. While not increasing the actual resolution of the
508508
spectrum (the minimum distance between resolvable peaks), this can give
509509
more points in the plot, allowing for more detail. This corresponds to
510-
the *n* parameter in the call to fft(). The default is None, which sets
511-
*pad_to* equal to *NFFT*
510+
the *n* parameter in the call to `~numpy.fft.fft`. The default is None,
511+
which sets *pad_to* equal to *NFFT*
512512
513513
NFFT : int, default: 256
514514
The number of data points used in each block for the FFT. A power 2 is
@@ -526,7 +526,7 @@ def _single_spectrum_helper(
526526
527527
scale_by_freq : bool, default: True
528528
Whether the resulting density values should be scaled by the scaling
529-
frequency, which gives density in units of Hz^-1. This allows for
529+
frequency, which gives density in units of 1/Hz. This allows for
530530
integration over the returned frequency values. The default is True for
531531
MATLAB compatibility.""")
532532

@@ -714,11 +714,11 @@ def specgram(x, NFFT=None, Fs=None, detrend=None, window=None,
714714
"""
715715
Compute a spectrogram.
716716
717-
Compute and plot a spectrogram of data in x. Data are split into
718-
NFFT length segments and the spectrum of each section is
719-
computed. The windowing function window is applied to each
717+
Compute and plot a spectrogram of data in *x*. Data are split into
718+
*NFFT* length segments and the spectrum of each section is
719+
computed. The windowing function *window* is applied to each
720720
segment, and the amount of overlap of each segment is
721-
specified with noverlap.
721+
specified with *noverlap*.
722722
723723
Parameters
724724
----------
@@ -760,13 +760,13 @@ def specgram(x, NFFT=None, Fs=None, detrend=None, window=None,
760760
--------
761761
psd : differs in the overlap and in the return values.
762762
complex_spectrum : similar, but with complex valued frequencies.
763-
magnitude_spectrum : similar single segment when mode is 'magnitude'.
764-
angle_spectrum : similar to single segment when mode is 'angle'.
765-
phase_spectrum : similar to single segment when mode is 'phase'.
763+
magnitude_spectrum : similar single segment when *mode* is 'magnitude'.
764+
angle_spectrum : similar to single segment when *mode* is 'angle'.
765+
phase_spectrum : similar to single segment when *mode* is 'phase'.
766766
767767
Notes
768768
-----
769-
detrend and scale_by_freq only apply when *mode* is set to 'psd'.
769+
*detrend* and *scale_by_freq* only apply when *mode* is set to 'psd'.
770770
771771
"""
772772
if noverlap is None:

0 commit comments

Comments
 (0)