Skip to content

Commit 2b42d85

Browse files
joelostblomemmanuelle
authored andcommitted
Docstring touchups (#1866)
* Reduce line width to prevent wrapping in Jupyter Notebook help dialog * Correct trendline docstring * Unify language in "one of" docstrings * Mention "suspectedoutliers" as a legal argument to the points parameter This already shows up in the error message when passing "points" an illegal argument * Document extension of whiskers when no sample points are plotted The docstring already mentions that the points parameter can be used to control the whisker length, but it does not document how which lead to #522 * Document box and whisker ranges * Mention whisker extension at one more place * Add newline in boxplot description
1 parent a3d9d30 commit 2b42d85

File tree

5 files changed

+32
-22
lines changed

5 files changed

+32
-22
lines changed

Diff for: packages/python/plotly/plotly/express/_chart_types.py

+6
Original file line numberDiff line numberDiff line change
@@ -461,6 +461,12 @@ def box(
461461
"""
462462
In a box plot, rows of `data_frame` are grouped together into a
463463
box-and-whisker mark to visualize their distribution.
464+
465+
Each box spans from quartile 1 (Q1) to quartile 3 (Q3). The
466+
second quartile (Q2) is marked by a line inside the box. By
467+
default, the whiskers correspond to the box' edges +/- 1.5
468+
times the interquartile range (IQR: Q3-Q1), see "points" for
469+
other options.
464470
"""
465471
return make_figure(
466472
args=locals(),

Diff for: packages/python/plotly/plotly/express/_doc.py

+14-12
Original file line numberDiff line numberDiff line change
@@ -302,22 +302,22 @@
302302
],
303303
marginal=[
304304
"str",
305-
"One of `'rug'`, `'box'`, `'violin'`, `'histogram'`.",
305+
"One of `'rug'`, `'box'`, `'violin'`, or `'histogram'`.",
306306
"If set, a subplot is drawn alongside the main plot, visualizing the distribution.",
307307
],
308308
marginal_x=[
309309
"str",
310-
"One of `'rug'`, `'box'`, `'violin'`, `'histogram'`.",
310+
"One of `'rug'`, `'box'`, `'violin'`, or `'histogram'`.",
311311
"If set, a horizontal subplot is drawn above the main plot, visualizing the x-distribution.",
312312
],
313313
marginal_y=[
314314
"str",
315-
"One of `'rug'`, `'box'`, `'violin'`, `'histogram'`.",
315+
"One of `'rug'`, `'box'`, `'violin'`, or `'histogram'`.",
316316
"If set, a vertical subplot is drawn to the right of the main plot, visualizing the y-distribution.",
317317
],
318318
trendline=[
319319
"str",
320-
"One of `'rug'`, `'box'`, `'violin'`, `'histogram'`.",
320+
"One of `'ols'` or `'lowess'`.",
321321
"If `'ols'`, an Ordinary Least Squares regression line will be drawn for each discrete-color/symbol group.",
322322
"If `'lowess`', a Locally Weighted Scatterplot Smoothing line will be drawn for each discrete-color/symbol group.",
323323
],
@@ -336,7 +336,7 @@
336336
],
337337
direction=[
338338
"str",
339-
"One of '`counterclockwise'`, `'clockwise'`. Default is `'clockwise'`",
339+
"One of '`counterclockwise'` or `'clockwise'`. Default is `'clockwise'`",
340340
"Sets the direction in which increasing values of the angular axis are drawn.",
341341
],
342342
start_angle=[
@@ -345,15 +345,15 @@
345345
],
346346
histfunc=[
347347
"str (default `'count'`)",
348-
"One of `'count'`, `'sum'`, `'avg'`, `'min'`, `'max'`."
348+
"One of `'count'`, `'sum'`, `'avg'`, `'min'`, or `'max'`."
349349
"Function used to aggregate values for summarization (note: can be normalized with `histnorm`).",
350350
"The arguments to this function for `histogram` are the values of `y` if `orientation` is `'v'`,",
351351
"otherwise the arguements are the values of `x`.",
352352
"The arguments to this function for `density_heatmap` and `density_contour` are the values of `z`.",
353353
],
354354
histnorm=[
355355
"str (default `None`)",
356-
"One of `'percent'`, `'probability'`, `'density'`, `'probability density'`",
356+
"One of `'percent'`, `'probability'`, `'density'`, or `'probability density'`",
357357
"If `None`, the output of `histfunc` is used as is.",
358358
"If `'probability'`, the output of `histfunc` for a given bin is divided by the sum of the output of `histfunc` for all bins.",
359359
"If `'percent'`, the output of `histfunc` for a given bin is divided by the sum of the output of `histfunc` for all bins and multiplied by 100.",
@@ -411,12 +411,12 @@
411411
line_shape=["str (default `'linear'`)", "One of `'linear'` or `'spline'`."],
412412
scope=[
413413
"str (default `'world'`).",
414-
"One of `'world'`, `'usa'`, `'europe'`, `'asia'`, `'africa'`, `'north america'`, `'south america'`)"
414+
"One of `'world'`, `'usa'`, `'europe'`, `'asia'`, `'africa'`, `'north america'`, or `'south america'`)"
415415
"Default is `'world'` unless `projection` is set to `'albers usa'`, which forces `'usa'`.",
416416
],
417417
projection=[
418418
"str ",
419-
"One of `'equirectangular'`, `'mercator'`, `'orthographic'`, `'natural earth'`, `'kavrayskiy7'`, `'miller'`, `'robinson'`, `'eckert4'`, `'azimuthal equal area'`, `'azimuthal equidistant'`, `'conic equal area'`, `'conic conformal'`, `'conic equidistant'`, `'gnomonic'`, `'stereographic'`, `'mollweide'`, `'hammer'`, `'transverse mercator'`, `'albers usa'`, `'winkel tripel'`, `'aitoff'`, `'sinusoidal'`"
419+
"One of `'equirectangular'`, `'mercator'`, `'orthographic'`, `'natural earth'`, `'kavrayskiy7'`, `'miller'`, `'robinson'`, `'eckert4'`, `'azimuthal equal area'`, `'azimuthal equidistant'`, `'conic equal area'`, `'conic conformal'`, `'conic equidistant'`, `'gnomonic'`, `'stereographic'`, `'mollweide'`, `'hammer'`, `'transverse mercator'`, `'albers usa'`, `'winkel tripel'`, `'aitoff'`, or `'sinusoidal'`"
420420
"Default depends on `scope`.",
421421
],
422422
center=[
@@ -426,10 +426,12 @@
426426
],
427427
points=[
428428
"str or boolean (default `'outliers'`)",
429-
"One of `'all'`, `'outliers'`, or `False`.",
429+
"One of `'outliers'`, `'suspectedoutliers'`, `'all'`, or `False`.",
430+
"If `'outliers'`, only the sample points lying outside the whiskers are shown.",
431+
"If `'suspectedoutliers'`, all outlier points are shown and those less than 4*Q1-3*Q3 or greater than 4*Q3-3*Q1 are highlighted with the marker's `'outliercolor'`.",
430432
"If `'outliers'`, only the sample points lying outside the whiskers are shown.",
431433
"If `'all'`, all sample points are shown.",
432-
"If `False`, no sample points are shown",
434+
"If `False`, no sample points are shown and the whiskers extend to the full range of the sample.",
433435
],
434436
box=["boolean (default `False`)", "If `True`, boxes are drawn inside the violins."],
435437
notched=["boolean (default `False`)", "If `True`, boxes are drawn with notches."],
@@ -444,7 +446,7 @@
444446

445447

446448
def make_docstring(fn):
447-
tw = TextWrapper(width=79, initial_indent=" ", subsequent_indent=" ")
449+
tw = TextWrapper(width=77, initial_indent=" ", subsequent_indent=" ")
448450
result = (fn.__doc__ or "") + "\nParameters\n----------\n"
449451
for param in inspect.getargspec(fn)[0]:
450452
param_desc_list = docs[param][1:]

Diff for: packages/python/plotly/plotly/graph_objs/__init__.py

+8-6
Original file line numberDiff line numberDiff line change
@@ -5533,7 +5533,8 @@ def points(self):
55335533
are shown and points either less than 4*Q1-3*Q3 or greater than
55345534
4*Q3-3*Q1 are highlighted (see `outliercolor`) If "all", all
55355535
sample points are shown If False, only the violins are shown
5536-
with no sample points
5536+
with no sample points and the whiskers extend to the range of the
5537+
sample.
55375538

55385539
The 'points' property is an enumeration that may be specified as:
55395540
- One of the following enumeration values:
@@ -6278,7 +6279,7 @@ def _prop_descriptions(self):
62786279
or greater than 4*Q3-3*Q1 are highlighted (see
62796280
`outliercolor`) If "all", all sample points are shown
62806281
If False, only the violins are shown with no sample
6281-
points
6282+
points and the whiskers extend to the range of the sample.
62826283
scalegroup
62836284
If there are multiple violins that should be sized
62846285
according to to some metric (see `scalemode`), link
@@ -6610,7 +6611,7 @@ def __init__(
66106611
or greater than 4*Q3-3*Q1 are highlighted (see
66116612
`outliercolor`) If "all", all sample points are shown
66126613
If False, only the violins are shown with no sample
6613-
points
6614+
points and the whiskers extend to the range of the sample.
66146615
scalegroup
66156616
If there are multiple violins that should be sized
66166617
according to to some metric (see `scalemode`), link
@@ -83296,7 +83297,8 @@ def boxpoints(self):
8329683297
are shown and points either less than 4*Q1-3*Q3 or greater than
8329783298
4*Q3-3*Q1 are highlighted (see `outliercolor`) If "all", all
8329883299
sample points are shown If False, only the box(es) are shown
83299-
with no sample points
83300+
with no sample points and the whiskers extend to the range of the
83301+
sample.
8330083302

8330183303
The 'boxpoints' property is an enumeration that may be specified as:
8330283304
- One of the following enumeration values:
@@ -84562,7 +84564,7 @@ def _prop_descriptions(self):
8456284564
or greater than 4*Q3-3*Q1 are highlighted (see
8456384565
`outliercolor`) If "all", all sample points are shown
8456484566
If False, only the box(es) are shown with no sample
84565-
points
84567+
points and the whiskers extend to the range of the sample.
8456684568
customdata
8456784569
Assigns extra data each datum. This may be useful when
8456884570
listening to hover, click and selection events. Note
@@ -84868,7 +84870,7 @@ def __init__(
8486884870
or greater than 4*Q3-3*Q1 are highlighted (see
8486984871
`outliercolor`) If "all", all sample points are shown
8487084872
If False, only the box(es) are shown with no sample
84871-
points
84873+
points and the whiskers extend to the range of the sample.
8487284874
customdata
8487384875
Assigns extra data each datum. This may be useful when
8487484876
listening to hover, click and selection events. Note

Diff for: packages/python/plotly/plotly/graph_objs/_figure.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -1613,7 +1613,7 @@ def add_box(
16131613
or greater than 4*Q3-3*Q1 are highlighted (see
16141614
`outliercolor`) If "all", all sample points are shown
16151615
If False, only the box(es) are shown with no sample
1616-
points
1616+
points and the whiskers extend to the range of the sample.
16171617
customdata
16181618
Assigns extra data each datum. This may be useful when
16191619
listening to hover, click and selection events. Note
@@ -14865,7 +14865,7 @@ def add_violin(
1486514865
or greater than 4*Q3-3*Q1 are highlighted (see
1486614866
`outliercolor`) If "all", all sample points are shown
1486714867
If False, only the violins are shown with no sample
14868-
points
14868+
points and the whiskers extend to the range of the sample.
1486914869
scalegroup
1487014870
If there are multiple violins that should be sized
1487114871
according to to some metric (see `scalemode`), link

Diff for: packages/python/plotly/plotly/graph_objs/_figurewidget.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -1613,7 +1613,7 @@ def add_box(
16131613
or greater than 4*Q3-3*Q1 are highlighted (see
16141614
`outliercolor`) If "all", all sample points are shown
16151615
If False, only the box(es) are shown with no sample
1616-
points
1616+
points and the whiskers extend to the range of the sample.
16171617
customdata
16181618
Assigns extra data each datum. This may be useful when
16191619
listening to hover, click and selection events. Note
@@ -14865,7 +14865,7 @@ def add_violin(
1486514865
or greater than 4*Q3-3*Q1 are highlighted (see
1486614866
`outliercolor`) If "all", all sample points are shown
1486714867
If False, only the violins are shown with no sample
14868-
points
14868+
points and the whiskers extend to the range of the sample.
1486914869
scalegroup
1487014870
If there are multiple violins that should be sized
1487114871
according to to some metric (see `scalemode`), link

0 commit comments

Comments
 (0)