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

Skip to content

Commit d36ba9c

Browse files
committed
Fixes to boxplot() docstring & error messages.
1 parent 8990a43 commit d36ba9c

File tree

1 file changed

+29
-35
lines changed

1 file changed

+29
-35
lines changed

lib/matplotlib/axes/_axes.py

Lines changed: 29 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -3463,8 +3463,8 @@ def boxplot(self, x, notch=None, sym=None, vert=None, whis=None,
34633463
"""
34643464
Make a box and whisker plot.
34653465
3466-
Make a box and whisker plot for each column of ``x`` or each
3467-
vector in sequence ``x``. The box extends from the lower to
3466+
Make a box and whisker plot for each column of *x* or each
3467+
vector in sequence *x*. The box extends from the lower to
34683468
upper quartile values of the data, with a line at the median.
34693469
The whiskers extend from the box to show the range of the
34703470
data. Flier points are those past the end of the whiskers.
@@ -3475,11 +3475,10 @@ def boxplot(self, x, notch=None, sym=None, vert=None, whis=None,
34753475
The input data.
34763476
34773477
notch : bool, default: False
3478-
If `True`, will produce a notched box plot. Otherwise, a
3479-
rectangular boxplot is produced. The notches represent the
3480-
confidence interval (CI) around the median. See the entry
3481-
for the ``bootstrap`` parameter for information regarding
3482-
how the locations of the notches are computed.
3478+
Whether to draw a noteched box plot (`True`), or a rectangular box
3479+
plot (`False`). The notches represent the confidence interval (CI)
3480+
around the median. The documentation for *bootstrap* describes how
3481+
the locations of the notches are computed.
34833482
34843483
.. note::
34853484
@@ -3491,10 +3490,9 @@ def boxplot(self, x, notch=None, sym=None, vert=None, whis=None,
34913490
visualization packages.
34923491
34933492
sym : str, optional
3494-
The default symbol for flier points. Enter an empty string
3495-
('') if you don't want to show fliers. If `None`, then the
3496-
fliers default to 'b+' If you want more control use the
3497-
flierprops kwarg.
3493+
The default symbol for flier points. An empty string ('') hides
3494+
the fliers. If `None`, then the fliers default to 'b+'. More
3495+
control is provided by the *flierprops* parameter.
34983496
34993497
vert : bool, default: True
35003498
If `True`, draws vertical boxes.
@@ -3523,7 +3521,7 @@ def boxplot(self, x, notch=None, sym=None, vert=None, whis=None,
35233521
35243522
bootstrap : int, optional
35253523
Specifies whether to bootstrap the confidence intervals
3526-
around the median for notched boxplots. If ``bootstrap`` is
3524+
around the median for notched boxplots. If *bootstrap* is
35273525
None, no bootstrapping is performed, and notches are
35283526
calculated using a Gaussian-based asymptotic approximation
35293527
(see McGill, R., Tukey, J.W., and Larsen, W.A., 1978, and
@@ -3533,20 +3531,17 @@ def boxplot(self, x, notch=None, sym=None, vert=None, whis=None,
35333531
recommended.
35343532
35353533
usermedians : array-like, optional
3536-
An array or sequence whose first dimension (or length) is
3537-
compatible with ``x``. This overrides the medians computed
3538-
by matplotlib for each element of ``usermedians`` that is not
3539-
`None`. When an element of ``usermedians`` is None, the median
3540-
will be computed by matplotlib as normal.
3534+
A 1D array-like of length ``len(x)``. Each entry that is not
3535+
`None` forces the value of the median for the corresponding
3536+
dataset. For entries that are `None`, the medians are computed
3537+
by Matplotlib as normal.
35413538
35423539
conf_intervals : array-like, optional
3543-
Array or sequence whose first dimension (or length) is
3544-
compatible with ``x`` and whose second dimension is 2. When
3545-
the an element of ``conf_intervals`` is not None, the
3546-
notch locations computed by matplotlib are overridden
3547-
(provided ``notch`` is `True`). When an element of
3548-
``conf_intervals`` is `None`, the notches are computed by the
3549-
method specified by the other kwargs (e.g., ``bootstrap``).
3540+
A 2D array-like of shape ``(len(x), 2)``. Each entry that is not
3541+
None forces the location of the corresponding notch (which is
3542+
only drawn if *notch* is `True`). For entries that are `None`,
3543+
the notches are computed by the method specified by the other
3544+
parameters (e.g., *bootstrap*).
35503545
35513546
positions : array-like, optional
35523547
Sets the positions of the boxes. The ticks and limits are
@@ -3563,24 +3558,22 @@ def boxplot(self, x, notch=None, sym=None, vert=None, whis=None,
35633558
boxes and drawn with Patch artists.
35643559
35653560
labels : sequence, optional
3566-
Labels for each dataset. Length must be compatible with
3567-
dimensions of ``x``.
3561+
Labels for each dataset (one per dataset).
35683562
35693563
manage_ticks : bool, default: True
35703564
If True, the tick locations and labels will be adjusted to match
35713565
the boxplot positions.
35723566
35733567
autorange : bool, default: False
35743568
When `True` and the data are distributed such that the 25th and
3575-
75th percentiles are equal, ``whis`` is set to (0, 100) such
3569+
75th percentiles are equal, *whis* is set to (0, 100) such
35763570
that the whisker ends are at the minimum and maximum of the data.
35773571
35783572
meanline : bool, default: False
3579-
If `True` (and ``showmeans`` is `True`), will try to render
3580-
the mean as a line spanning the full width of the box
3581-
according to ``meanprops`` (see below). Not recommended if
3582-
``shownotches`` is also True. Otherwise, means will be shown
3583-
as points.
3573+
If `True` (and *showmeans* is `True`), will try to render the
3574+
mean as a line spanning the full width of the box according to
3575+
*meanprops* (see below). Not recommended if *shownotches* is also
3576+
True. Otherwise, means will be shown as points.
35843577
35853578
zorder : scalar, default: None
35863579
Sets the zorder of the boxplot.
@@ -3712,7 +3705,8 @@ def boxplot(self, x, notch=None, sym=None, vert=None, whis=None,
37123705
if usermedians is not None:
37133706
if (len(np.ravel(usermedians)) != len(bxpstats) or
37143707
np.shape(usermedians)[0] != len(bxpstats)):
3715-
raise ValueError('usermedians length not compatible with x')
3708+
raise ValueError(
3709+
"'usermedians' and 'x' have different lengths")
37163710
else:
37173711
# reassign medians as necessary
37183712
for stats, med in zip(bxpstats, usermedians):
@@ -3721,8 +3715,8 @@ def boxplot(self, x, notch=None, sym=None, vert=None, whis=None,
37213715

37223716
if conf_intervals is not None:
37233717
if np.shape(conf_intervals)[0] != len(bxpstats):
3724-
err_mess = 'conf_intervals length not compatible with x'
3725-
raise ValueError(err_mess)
3718+
raise ValueError(
3719+
"'conf_intervals' and 'x' have different lengths")
37263720
else:
37273721
for stats, ci in zip(bxpstats, conf_intervals):
37283722
if ci is not None:

0 commit comments

Comments
 (0)