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

Skip to content

Commit fa1183c

Browse files
committed
Examples of parameter renames.
1 parent 8367723 commit fa1183c

File tree

5 files changed

+30
-15
lines changed

5 files changed

+30
-15
lines changed
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
Changes in parameter names
2+
``````````````````````````
3+
4+
- The ``arg`` argument to `matplotlib.use` has been renamed to ``backend``.
5+
- The ``normed`` argument to `Axes.hist2d` has been renamed to ``density``.
6+
- The ``s`` argument to `Annotation` (and indirectly `Axes.annotation`) has
7+
been renamed to ``text``.
8+
9+
In each case, the old argument name remains supported (it cannot be used
10+
simultaneously with the new name), but suppport for it will be dropped in
11+
Matplotlib 3.3.

lib/matplotlib/__init__.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1171,13 +1171,14 @@ def __exit__(self, exc_type, exc_value, exc_tb):
11711171
self.__fallback()
11721172

11731173

1174-
def use(arg, warn=False, force=True):
1174+
@cbook._rename_parameter("3.1", "arg", "backend")
1175+
def use(backend, warn=False, force=True):
11751176
"""
11761177
Set the matplotlib backend to one of the known backends.
11771178
11781179
Parameters
11791180
----------
1180-
arg : str
1181+
backend : str
11811182
The backend to switch to. This can either be one of the
11821183
'standard' backend names:
11831184
@@ -1209,7 +1210,7 @@ def use(arg, warn=False, force=True):
12091210
:ref:`backends`
12101211
matplotlib.get_backend
12111212
"""
1212-
name = validate_backend(arg)
1213+
name = validate_backend(backend)
12131214

12141215
# if setting back to the same thing, do nothing
12151216
if (dict.__getitem__(rcParams, 'backend') == name):

lib/matplotlib/axes/_axes.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6809,7 +6809,8 @@ def hist(self, x, bins=None, range=None, density=None, weights=None,
68096809
return tops, bins, cbook.silent_list('Lists of Patches', patches)
68106810

68116811
@_preprocess_data(replace_names=["x", "y", "weights"])
6812-
def hist2d(self, x, y, bins=10, range=None, normed=False, weights=None,
6812+
@cbook._rename_parameter("3.1", "normed", "density")
6813+
def hist2d(self, x, y, bins=10, range=None, density=False, weights=None,
68136814
cmin=None, cmax=None, **kwargs):
68146815
"""
68156816
Make a 2D histogram plot.
@@ -6843,8 +6844,9 @@ def hist2d(self, x, y, bins=10, range=None, normed=False, weights=None,
68436844
xmax], [ymin, ymax]]``. All values outside of this range will be
68446845
considered outliers and not tallied in the histogram.
68456846
6846-
normed : bool, optional, default: False
6847-
Normalize histogram.
6847+
density : bool, optional, default: False
6848+
Normalize histogram. *normed* is a deprecated synonym for the
6849+
same functionality.
68486850
68496851
weights : array_like, shape (n, ), optional, default: None
68506852
An array of values w_i weighing each sample (x_i, y_i).
@@ -6903,7 +6905,7 @@ def hist2d(self, x, y, bins=10, range=None, normed=False, weights=None,
69036905
"""
69046906

69056907
h, xedges, yedges = np.histogram2d(x, y, bins=bins, range=range,
6906-
normed=normed, weights=weights)
6908+
normed=density, weights=weights)
69076909

69086910
if cmin is not None:
69096911
h[h < cmin] = None

lib/matplotlib/pyplot.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2631,12 +2631,12 @@ def hist(
26312631
# Autogenerated by boilerplate.py. Do not edit as changes will be lost.
26322632
@_autogen_docstring(Axes.hist2d)
26332633
def hist2d(
2634-
x, y, bins=10, range=None, normed=False, weights=None,
2634+
x, y, bins=10, range=None, density=False, weights=None,
26352635
cmin=None, cmax=None, *, data=None, **kwargs):
26362636
__ret = gca().hist2d(
2637-
x, y, bins=bins, range=range, normed=normed, weights=weights,
2638-
cmin=cmin, cmax=cmax, **({"data": data} if data is not None
2639-
else {}), **kwargs)
2637+
x, y, bins=bins, range=range, density=density,
2638+
weights=weights, cmin=cmin, cmax=cmax, **({"data": data} if
2639+
data is not None else {}), **kwargs)
26402640
sci(__ret[-1])
26412641
return __ret
26422642

lib/matplotlib/text.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1957,15 +1957,16 @@ class Annotation(Text, _AnnotationBase):
19571957
def __str__(self):
19581958
return "Annotation(%g, %g, %r)" % (self.xy[0], self.xy[1], self._text)
19591959

1960-
def __init__(self, s, xy,
1960+
@cbook._rename_parameter("3.1", "s", "text")
1961+
def __init__(self, text, xy,
19611962
xytext=None,
19621963
xycoords='data',
19631964
textcoords=None,
19641965
arrowprops=None,
19651966
annotation_clip=None,
19661967
**kwargs):
19671968
"""
1968-
Annotate the point *xy* with text *s*.
1969+
Annotate the point *xy* with text *text*.
19691970
19701971
In the simplest form, the text is placed at *xy*.
19711972
@@ -1975,7 +1976,7 @@ def __init__(self, s, xy,
19751976
19761977
Parameters
19771978
----------
1978-
s : str
1979+
text : str
19791980
The text of the annotation.
19801981
19811982
xy : (float, float)
@@ -2151,7 +2152,7 @@ def transform(renderer) -> Transform
21512152
xytext = self.xy
21522153
x, y = xytext
21532154

2154-
Text.__init__(self, x, y, s, **kwargs)
2155+
Text.__init__(self, x, y, text, **kwargs)
21552156

21562157
self.arrowprops = arrowprops
21572158

0 commit comments

Comments
 (0)