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

Skip to content

Commit d366cbb

Browse files
authored
Merge branch 'matplotlib:main' into documentation_1
2 parents ba5d33c + 61ed3f4 commit d366cbb

File tree

28 files changed

+207
-160
lines changed

28 files changed

+207
-160
lines changed

.github/workflows/tests.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,7 @@ jobs:
103103
libgirepository1.0-dev \
104104
libsdl2-2.0-0 \
105105
libxkbcommon-x11-0 \
106+
libxcb-cursor0 \
106107
libxcb-icccm4 \
107108
libxcb-image0 \
108109
libxcb-keysyms1 \

ci/mypy-stubtest-allowlist.txt

Lines changed: 0 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -64,38 +64,9 @@ matplotlib.ticker.MultipleLocator.set_params
6464
matplotlib.text.Annotation.get_window_extent
6565

6666
# Inconsistent super/sub class parameter name (maybe rename for consistency)
67-
matplotlib.axis.Axis.set_clip_path
68-
matplotlib.axis.Tick.set_clip_path
69-
matplotlib.image.NonUniformImage.set_filternorm
70-
matplotlib.image.NonUniformImage.set_filterrad
71-
matplotlib.projections.geo.AitoffAxes.AitoffTransform.transform_non_affine
72-
matplotlib.projections.geo.AitoffAxes.InvertedAitoffTransform.transform_non_affine
73-
matplotlib.projections.geo.HammerAxes.HammerTransform.transform_non_affine
74-
matplotlib.projections.geo.HammerAxes.InvertedHammerTransform.transform_non_affine
75-
matplotlib.projections.geo.LambertAxes.InvertedLambertTransform.transform_non_affine
76-
matplotlib.projections.geo.LambertAxes.LambertTransform.transform_non_affine
77-
matplotlib.projections.geo.MollweideAxes.InvertedMollweideTransform.transform_non_affine
78-
matplotlib.projections.geo.MollweideAxes.MollweideTransform.transform_non_affine
79-
matplotlib.projections.polar.InvertedPolarTransform.transform_non_affine
80-
matplotlib.projections.polar.PolarTransform.transform_non_affine
8167
matplotlib.projections.polar.RadialLocator.nonsingular
82-
matplotlib.scale.AsinhTransform.transform_non_affine
83-
matplotlib.scale.InvertedAsinhTransform.transform_non_affine
84-
matplotlib.scale.InvertedSymmetricalLogTransform.transform_non_affine
85-
matplotlib.scale.LogisticTransform.transform_non_affine
86-
matplotlib.scale.LogitTransform.transform_non_affine
87-
matplotlib.scale.SymmetricalLogTransform.transform_non_affine
88-
matplotlib.table.Cell.set_transform
8968
matplotlib.ticker.LogLocator.nonsingular
9069
matplotlib.ticker.LogitLocator.nonsingular
91-
matplotlib.transforms.Affine2DBase.transform_affine
92-
matplotlib.transforms.AffineBase.transform_non_affine
93-
matplotlib.transforms.BlendedGenericTransform.transform_non_affine
94-
matplotlib.transforms.CompositeGenericTransform.transform_affine
95-
matplotlib.transforms.CompositeGenericTransform.transform_non_affine
96-
matplotlib.transforms.IdentityTransform.transform_affine
97-
matplotlib.transforms.IdentityTransform.transform_non_affine
98-
matplotlib.transforms.IdentityTransform.transform
9970

10071
# Stdlib/Enum considered inconsistent (no fault of ours, I don't think)
10172
matplotlib.backend_bases._Mode.__new__
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
Method parameters renamed to match base classes
2+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
3+
4+
The only parameter of ``transform_affine`` and ``transform_non_affine`` in ``Transform`` subclasses is renamed
5+
to *values*.
6+
7+
The *points* parameter of ``transforms.IdentityTransform.transform`` is renamed to *values*.
8+
9+
The *trans* parameter of ``table.Cell.set_transform`` is renamed to *t* consistently with
10+
`.Artist.set_transform`.
11+
12+
The *clippath* parameters of ``axis.Axis.set_clip_path`` and ``axis.Tick.set_clip_path`` are
13+
renamed to *path* consistently with `.Artist.set_clip_path`.
14+
15+
The *s* parameter of ``images.NonUniformImage.set_filternorm`` is renamed to *filternorm*
16+
consistently with ```_ImageBase.set_filternorm``.
17+
18+
The *s* parameter of ``images.NonUniformImage.set_filterrad`` is renamed to *filterrad*
19+
consistently with ```_ImageBase.set_filterrad``.

environment.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ dependencies:
4949
- flake8-docstrings>=1.4.0
5050
- gtk4
5151
- ipykernel
52-
- nbconvert[execute]!=6.0.0,!=6.0.1
52+
- nbconvert[execute]!=6.0.0,!=6.0.1,!=7.3.0
5353
- nbformat!=5.0.0,!=5.0.1
5454
- pandas!=0.25.0
5555
- psutil

galleries/users_explain/text/README.txt

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,10 @@
55
Text
66
----
77

8-
matplotlib has extensive text support, including support for
9-
mathematical expressions, truetype support for raster and
8+
Matplotlib has extensive text support, including support for
9+
mathematical expressions, TrueType support for raster and
1010
vector outputs, newline separated text with arbitrary
1111
rotations, and Unicode support. These tutorials cover
1212
the basics of working with text in Matplotlib.
13+
14+
For even more information see the :ref:`examples page <text_labels_and_annotations>`.

lib/matplotlib/axes/_axes.py

Lines changed: 17 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -314,7 +314,7 @@ def legend(self, *args, **kwargs):
314314
*args,
315315
**kwargs)
316316
if len(extra_args):
317-
raise TypeError('legend only accepts two non-keyword arguments')
317+
_api.nargs_error('legend', '0-2', len(args))
318318
self.legend_ = mlegend.Legend(self, handles, labels, **kwargs)
319319
self.legend_._remove_method = self._remove_legend
320320
return self.legend_
@@ -2830,11 +2830,11 @@ def broken_barh(self, xranges, yrange, **kwargs):
28302830
Parameters
28312831
----------
28322832
xranges : sequence of tuples (*xmin*, *xwidth*)
2833-
The x-positions and extends of the rectangles. For each tuple
2833+
The x-positions and extents of the rectangles. For each tuple
28342834
(*xmin*, *xwidth*) a rectangle is drawn from *xmin* to *xmin* +
28352835
*xwidth*.
28362836
yrange : (*ymin*, *yheight*)
2837-
The y-position and extend for all the rectangles.
2837+
The y-position and extent for all the rectangles.
28382838
28392839
Returns
28402840
-------
@@ -2970,8 +2970,7 @@ def stem(self, *args, linefmt=None, markerfmt=None, basefmt=None, bottom=0,
29702970
which inspired this method.
29712971
"""
29722972
if not 1 <= len(args) <= 3:
2973-
raise TypeError('stem expected between 1 or 3 positional '
2974-
f'arguments, got {args}')
2973+
_api.nargs_error('stem', '1-3', len(args))
29752974
_api.check_in_list(['horizontal', 'vertical'], orientation=orientation)
29762975

29772976
if len(args) == 1:
@@ -4455,6 +4454,18 @@ def scatter(self, x, y, s=None, c=None, marker=None, cmap=None, norm=None,
44554454
The marker size in points**2 (typographic points are 1/72 in.).
44564455
Default is ``rcParams['lines.markersize'] ** 2``.
44574456
4457+
The linewidth and edgecolor can visually interact with the marker
4458+
size, and can lead to artifacts if the marker size is smaller than
4459+
the linewidth.
4460+
4461+
If the linewidth is greater than 0 and the edgecolor is anything
4462+
but *'none'*, then the effective size of the marker will be
4463+
increased by half the linewidth because the stroke will be centered
4464+
on the edge of the shape.
4465+
4466+
To eliminate the marker edge either set *linewidth=0* or
4467+
*edgecolor='none'*.
4468+
44584469
c : array-like or list of colors or color, optional
44594470
The marker colors. Possible values:
44604471
@@ -6371,7 +6382,7 @@ def pcolorfast(self, *args, alpha=None, norm=None, cmap=None, vmin=None,
63716382
else:
63726383
raise TypeError("arguments do not match valid signatures")
63736384
else:
6374-
raise TypeError("need 1 argument or 3 arguments")
6385+
_api.nargs_error('pcolorfast', '1 or 3', len(args))
63756386

63766387
if style == "quadmesh":
63776388
# data point in each cell is value at lower left corner

lib/matplotlib/axis.py

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -229,10 +229,11 @@ def get_children(self):
229229
self.gridline, self.label1, self.label2]
230230
return children
231231

232-
def set_clip_path(self, clippath, transform=None):
232+
@_api.rename_parameter("3.8", "clippath", "path")
233+
def set_clip_path(self, path, transform=None):
233234
# docstring inherited
234-
super().set_clip_path(clippath, transform)
235-
self.gridline.set_clip_path(clippath, transform)
235+
super().set_clip_path(path, transform)
236+
self.gridline.set_clip_path(path, transform)
236237
self.stale = True
237238

238239
def contains(self, mouseevent):
@@ -1079,10 +1080,11 @@ def _translate_tick_params(kw, reverse=False):
10791080
kwtrans.update(kw_)
10801081
return kwtrans
10811082

1082-
def set_clip_path(self, clippath, transform=None):
1083-
super().set_clip_path(clippath, transform)
1083+
@_api.rename_parameter("3.8", "clippath", "path")
1084+
def set_clip_path(self, path, transform=None):
1085+
super().set_clip_path(path, transform)
10841086
for child in self.majorTicks + self.minorTicks:
1085-
child.set_clip_path(clippath, transform)
1087+
child.set_clip_path(path, transform)
10861088
self.stale = True
10871089

10881090
def get_view_interval(self):

lib/matplotlib/backends/backend_cairo.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,8 @@
1515
try:
1616
import cairo
1717
if cairo.version_info < (1, 14, 0): # Introduced set_device_scale.
18-
raise ImportError
18+
raise ImportError(f"Cairo backend requires cairo>=1.14.0, "
19+
f"but only {cairo.version_info} is available")
1920
except ImportError:
2021
try:
2122
import cairocffi as cairo

lib/matplotlib/backends/backend_gtk3.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
except ValueError as e:
2222
# in this case we want to re-raise as ImportError so the
2323
# auto-backend selection logic correctly skips.
24-
raise ImportError from e
24+
raise ImportError(e) from e
2525

2626
from gi.repository import Gio, GLib, GObject, Gtk, Gdk
2727
from . import _backend_gtk

lib/matplotlib/backends/backend_gtk4.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
except ValueError as e:
2121
# in this case we want to re-raise as ImportError so the
2222
# auto-backend selection logic correctly skips.
23-
raise ImportError from e
23+
raise ImportError(e) from e
2424

2525
from gi.repository import Gio, GLib, Gtk, Gdk, GdkPixbuf
2626
from . import _backend_gtk

lib/matplotlib/figure.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3515,7 +3515,7 @@ def tight_layout(self, *, pad=1.08, h_pad=None, w_pad=None, rect=None):
35153515
and previous_engine is not None:
35163516
_api.warn_external('The figure layout has changed to tight')
35173517
finally:
3518-
self.set_layout_engine(None)
3518+
self.set_layout_engine('none')
35193519

35203520

35213521
def figaspect(arg):

lib/matplotlib/hatch.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -188,7 +188,7 @@ def _validate_hatch_pattern(hatch):
188188
invalids = ''.join(sorted(invalids))
189189
_api.warn_deprecated(
190190
'3.4',
191-
removal='3.8', # one release after custom hatches (#20690)
191+
removal='3.9', # one release after custom hatches (#20690)
192192
message=f'hatch must consist of a string of "{valid}" or '
193193
'None, but found the following invalid values '
194194
f'"{invalids}". Passing invalid values is deprecated '

lib/matplotlib/image.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1188,10 +1188,12 @@ def get_extent(self):
11881188
raise RuntimeError('Must set data first')
11891189
return self._Ax[0], self._Ax[-1], self._Ay[0], self._Ay[-1]
11901190

1191-
def set_filternorm(self, s):
1191+
@_api.rename_parameter("3.8", "s", "filternorm")
1192+
def set_filternorm(self, filternorm):
11921193
pass
11931194

1194-
def set_filterrad(self, s):
1195+
@_api.rename_parameter("3.8", "s", "filterrad")
1196+
def set_filterrad(self, filterrad):
11951197
pass
11961198

11971199
def set_norm(self, norm):

lib/matplotlib/legend.py

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1352,11 +1352,8 @@ def _parse_legend_args(axs, *args, handles=None, labels=None, **kwargs):
13521352

13531353
# Two arguments:
13541354
# * user defined handles and labels
1355-
elif len(args) >= 2:
1355+
else:
13561356
handles, labels = args[:2]
13571357
extra_args = args[2:]
13581358

1359-
else:
1360-
raise TypeError('Invalid arguments to legend.')
1361-
13621359
return handles, labels, extra_args, kwargs

lib/matplotlib/projections/geo.py

Lines changed: 25 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -251,9 +251,10 @@ class AitoffAxes(GeoAxes):
251251
class AitoffTransform(_GeoTransform):
252252
"""The base Aitoff transform."""
253253

254-
def transform_non_affine(self, ll):
254+
@_api.rename_parameter("3.8", "ll", "values")
255+
def transform_non_affine(self, values):
255256
# docstring inherited
256-
longitude, latitude = ll.T
257+
longitude, latitude = values.T
257258

258259
# Pre-compute some values
259260
half_long = longitude / 2.0
@@ -272,10 +273,11 @@ def inverted(self):
272273

273274
class InvertedAitoffTransform(_GeoTransform):
274275

275-
def transform_non_affine(self, xy):
276+
@_api.rename_parameter("3.8", "xy", "values")
277+
def transform_non_affine(self, values):
276278
# docstring inherited
277279
# MGDTODO: Math is hard ;(
278-
return np.full_like(xy, np.nan)
280+
return np.full_like(values, np.nan)
279281

280282
def inverted(self):
281283
# docstring inherited
@@ -297,9 +299,10 @@ class HammerAxes(GeoAxes):
297299
class HammerTransform(_GeoTransform):
298300
"""The base Hammer transform."""
299301

300-
def transform_non_affine(self, ll):
302+
@_api.rename_parameter("3.8", "ll", "values")
303+
def transform_non_affine(self, values):
301304
# docstring inherited
302-
longitude, latitude = ll.T
305+
longitude, latitude = values.T
303306
half_long = longitude / 2.0
304307
cos_latitude = np.cos(latitude)
305308
sqrt2 = np.sqrt(2.0)
@@ -314,9 +317,10 @@ def inverted(self):
314317

315318
class InvertedHammerTransform(_GeoTransform):
316319

317-
def transform_non_affine(self, xy):
320+
@_api.rename_parameter("3.8", "xy", "values")
321+
def transform_non_affine(self, values):
318322
# docstring inherited
319-
x, y = xy.T
323+
x, y = values.T
320324
z = np.sqrt(1 - (x / 4) ** 2 - (y / 2) ** 2)
321325
longitude = 2 * np.arctan((z * x) / (2 * (2 * z ** 2 - 1)))
322326
latitude = np.arcsin(y*z)
@@ -342,14 +346,15 @@ class MollweideAxes(GeoAxes):
342346
class MollweideTransform(_GeoTransform):
343347
"""The base Mollweide transform."""
344348

345-
def transform_non_affine(self, ll):
349+
@_api.rename_parameter("3.8", "ll", "values")
350+
def transform_non_affine(self, values):
346351
# docstring inherited
347352
def d(theta):
348353
delta = (-(theta + np.sin(theta) - pi_sin_l)
349354
/ (1 + np.cos(theta)))
350355
return delta, np.abs(delta) > 0.001
351356

352-
longitude, latitude = ll.T
357+
longitude, latitude = values.T
353358

354359
clat = np.pi/2 - np.abs(latitude)
355360
ihigh = clat < 0.087 # within 5 degrees of the poles
@@ -370,7 +375,7 @@ def d(theta):
370375
d = 0.5 * (3 * np.pi * e**2) ** (1.0/3)
371376
aux[ihigh] = (np.pi/2 - d) * np.sign(latitude[ihigh])
372377

373-
xy = np.empty(ll.shape, dtype=float)
378+
xy = np.empty(values.shape, dtype=float)
374379
xy[:, 0] = (2.0 * np.sqrt(2.0) / np.pi) * longitude * np.cos(aux)
375380
xy[:, 1] = np.sqrt(2.0) * np.sin(aux)
376381

@@ -382,9 +387,10 @@ def inverted(self):
382387

383388
class InvertedMollweideTransform(_GeoTransform):
384389

385-
def transform_non_affine(self, xy):
390+
@_api.rename_parameter("3.8", "xy", "values")
391+
def transform_non_affine(self, values):
386392
# docstring inherited
387-
x, y = xy.T
393+
x, y = values.T
388394
# from Equations (7, 8) of
389395
# https://mathworld.wolfram.com/MollweideProjection.html
390396
theta = np.arcsin(y / np.sqrt(2))
@@ -422,9 +428,10 @@ def __init__(self, center_longitude, center_latitude, resolution):
422428
self._center_longitude = center_longitude
423429
self._center_latitude = center_latitude
424430

425-
def transform_non_affine(self, ll):
431+
@_api.rename_parameter("3.8", "ll", "values")
432+
def transform_non_affine(self, values):
426433
# docstring inherited
427-
longitude, latitude = ll.T
434+
longitude, latitude = values.T
428435
clong = self._center_longitude
429436
clat = self._center_latitude
430437
cos_lat = np.cos(latitude)
@@ -455,9 +462,10 @@ def __init__(self, center_longitude, center_latitude, resolution):
455462
self._center_longitude = center_longitude
456463
self._center_latitude = center_latitude
457464

458-
def transform_non_affine(self, xy):
465+
@_api.rename_parameter("3.8", "xy", "values")
466+
def transform_non_affine(self, values):
459467
# docstring inherited
460-
x, y = xy.T
468+
x, y = values.T
461469
clong = self._center_longitude
462470
clat = self._center_latitude
463471
p = np.maximum(np.hypot(x, y), 1e-9)

lib/matplotlib/projections/polar.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -63,9 +63,10 @@ def _get_rorigin(self):
6363
return self._scale_transform.transform(
6464
(0, self._axis.get_rorigin()))[1]
6565

66-
def transform_non_affine(self, tr):
66+
@_api.rename_parameter("3.8", "tr", "values")
67+
def transform_non_affine(self, values):
6768
# docstring inherited
68-
theta, r = np.transpose(tr)
69+
theta, r = np.transpose(values)
6970
# PolarAxes does not use the theta transforms here, but apply them for
7071
# backwards-compatibility if not being used by it.
7172
if self._apply_theta_transforms and self._axis is not None:
@@ -214,9 +215,10 @@ def __init__(self, axis=None, use_rmin=True,
214215
use_rmin="_use_rmin",
215216
_apply_theta_transforms="_apply_theta_transforms")
216217

217-
def transform_non_affine(self, xy):
218+
@_api.rename_parameter("3.8", "xy", "values")
219+
def transform_non_affine(self, values):
218220
# docstring inherited
219-
x, y = xy.T
221+
x, y = values.T
220222
r = np.hypot(x, y)
221223
theta = (np.arctan2(y, x) + 2 * np.pi) % (2 * np.pi)
222224
# PolarAxes does not use the theta transforms here, but apply them for

0 commit comments

Comments
 (0)