Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit117d1db

Browse files
committed
Revert renaming labels to tick_labels in boxplot_stats()
This is up for debate: I'm only +0.2 here.The renaming was done in#27901, which renamed the parameter `labels`to `tick_labels` for `boxplot()` and `bxp()`.One can take two views here:- If `boxplot_stats()` is specifically for the input of `bxp()`, one can justify the renaming as being consistent with the `bxp()` signature. Note however, that the returned dict still contains the key "label" for back-compatibility. So that brings us an inconsistency between the parameter name and the returned dict key.- One can alternatively view `boxplot_stats()` as a generic function to define box parameters. Here, we'd only have a general `label` for the boy and no information that this should be used as tick label.If we could make a clean transition and also rename the dict key, Iwould tend to go with the first view. But the inevitable inconsistencyof the fist view let's me sway towards the second view, so that withthe revert, we've effectively not touched `boxplot_stats()`.
1 parent1c4c9af commit117d1db

File tree

5 files changed

+12
-18
lines changed

5 files changed

+12
-18
lines changed

‎galleries/examples/statistics/bxp.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
labels=list('ABCD')
2626

2727
# compute the boxplot stats
28-
stats=cbook.boxplot_stats(data,tick_labels=labels,bootstrap=10000)
28+
stats=cbook.boxplot_stats(data,labels=labels,bootstrap=10000)
2929

3030
# %%
3131
# After we've computed the stats, we can go through and change anything.

‎lib/matplotlib/axes/_axes.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4001,7 +4001,7 @@ def boxplot(self, x, notch=None, sym=None, vert=None, whis=None,
40014001
bootstrap=mpl.rcParams['boxplot.bootstrap']
40024002

40034003
bxpstats=cbook.boxplot_stats(x,whis=whis,bootstrap=bootstrap,
4004-
tick_labels=tick_labels,autorange=autorange)
4004+
labels=tick_labels,autorange=autorange)
40054005
ifnotchisNone:
40064006
notch=mpl.rcParams['boxplot.notch']
40074007
ifvertisNone:

‎lib/matplotlib/cbook.py

Lines changed: 7 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1126,9 +1126,7 @@ def _broadcast_with_masks(*args, compress=False):
11261126
returninputs
11271127

11281128

1129-
@_api.rename_parameter("3.9","labels","tick_labels")
1130-
defboxplot_stats(X,whis=1.5,bootstrap=None,tick_labels=None,
1131-
autorange=False):
1129+
defboxplot_stats(X,whis=1.5,bootstrap=None,labels=None,autorange=False):
11321130
r"""
11331131
Return a list of dictionaries of statistics used to draw a series of box
11341132
and whisker plots using `~.Axes.bxp`.
@@ -1162,14 +1160,10 @@ def boxplot_stats(X, whis=1.5, bootstrap=None, tick_labels=None,
11621160
Number of times the confidence intervals around the median
11631161
should be bootstrapped (percentile method).
11641162
1165-
tick_labels :array-like, optional
1163+
labels :list of str, optional
11661164
Labels for each dataset. Length must be compatible with
11671165
dimensions of *X*.
11681166
1169-
.. versionchanged:: 3.9
1170-
Renamed from *labels*, which is deprecated since 3.9
1171-
and will be removed in 3.11.
1172-
11731167
autorange : bool, optional (False)
11741168
When `True` and the data are distributed such that the 25th and 75th
11751169
percentiles are equal, ``whis`` is set to (0, 100) such that the
@@ -1245,13 +1239,13 @@ def _compute_conf_interval(data, med, iqr, bootstrap):
12451239
X=_reshape_2D(X,"X")
12461240

12471241
ncols=len(X)
1248-
iftick_labelsisNone:
1249-
tick_labels=itertools.repeat(None)
1250-
eliflen(tick_labels)!=ncols:
1251-
raiseValueError("Dimensions oftick_labels and X must be compatible")
1242+
iflabelsisNone:
1243+
labels=itertools.repeat(None)
1244+
eliflen(labels)!=ncols:
1245+
raiseValueError("Dimensions oflabels and X must be compatible")
12521246

12531247
input_whis=whis
1254-
forii, (x,label)inenumerate(zip(X,tick_labels)):
1248+
forii, (x,label)inenumerate(zip(X,labels)):
12551249

12561250
# empty dict
12571251
stats= {}

‎lib/matplotlib/cbook.pyi

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,7 @@ def boxplot_stats(
135135
X:ArrayLike,
136136
whis:float|tuple[float,float]= ...,
137137
bootstrap:int|None= ...,
138-
tick_labels:ArrayLike|None= ...,
138+
labels:ArrayLike|None= ...,
139139
autorange:bool= ...,
140140
)->list[dict[str,Any]]: ...
141141

‎lib/matplotlib/tests/test_cbook.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,7 @@ def test_results_whiskers_percentiles(self):
147147

148148
deftest_results_withlabels(self):
149149
labels= ['Test1',2,'Aardvark',4]
150-
results=cbook.boxplot_stats(self.data,tick_labels=labels)
150+
results=cbook.boxplot_stats(self.data,labels=labels)
151151
forlab,resinzip(labels,results):
152152
assertres['label']==lab
153153

@@ -158,7 +158,7 @@ def test_results_withlabels(self):
158158
deftest_label_error(self):
159159
labels= [1,2]
160160
withpytest.raises(ValueError):
161-
cbook.boxplot_stats(self.data,tick_labels=labels)
161+
cbook.boxplot_stats(self.data,labels=labels)
162162

163163
deftest_bad_dims(self):
164164
data=np.random.normal(size=(34,34,34))

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp