Skip to content

Commit d04d1c4

Browse files
committed
Improve documentation on boxplot and violinplot
1 parent 1defb57 commit d04d1c4

File tree

1 file changed

+40
-17
lines changed

1 file changed

+40
-17
lines changed

lib/matplotlib/axes/_axes.py

+40-17
Original file line numberDiff line numberDiff line change
@@ -3801,7 +3801,7 @@ def boxplot(self, x, notch=None, sym=None, vert=None, whis=None,
38013801
in *x*. If a sequence of 1D arrays, a boxplot is drawn for each
38023802
array in *x*.
38033803
3804-
notch : bool, default: False
3804+
notch : bool, default: :rc:`boxplot.notch`
38053805
Whether to draw a notched boxplot (`True`), or a rectangular
38063806
boxplot (`False`). The notches represent the confidence interval
38073807
(CI) around the median. The documentation for *bootstrap*
@@ -3823,7 +3823,7 @@ def boxplot(self, x, notch=None, sym=None, vert=None, whis=None,
38233823
the fliers. If `None`, then the fliers default to 'b+'. More
38243824
control is provided by the *flierprops* parameter.
38253825
3826-
vert : bool, default: True
3826+
vert : bool, default: :rc:`boxplot.vertical`
38273827
If `True`, draws vertical boxes.
38283828
If `False`, draw horizontal boxes.
38293829
@@ -3880,7 +3880,7 @@ def boxplot(self, x, notch=None, sym=None, vert=None, whis=None,
38803880
The widths of the boxes. The default is 0.5, or ``0.15*(distance
38813881
between extreme positions)``, if that is smaller.
38823882
3883-
patch_artist : bool, default: False
3883+
patch_artist : bool, default: :rc:`boxplot.patchartist`
38843884
If `False` produces boxes with the Line2D artist. Otherwise,
38853885
boxes are drawn with Patch artists.
38863886
@@ -3896,7 +3896,7 @@ def boxplot(self, x, notch=None, sym=None, vert=None, whis=None,
38963896
75th percentiles are equal, *whis* is set to (0, 100) such
38973897
that the whisker ends are at the minimum and maximum of the data.
38983898
3899-
meanline : bool, default: False
3899+
meanline : bool, default: :rc:`boxplot.meanline`
39003900
If `True` (and *showmeans* is `True`), will try to render the
39013901
mean as a line spanning the full width of the box according to
39023902
*meanprops* (see below). Not recommended if *shownotches* is also
@@ -3931,13 +3931,13 @@ def boxplot(self, x, notch=None, sym=None, vert=None, whis=None,
39313931
39323932
Other Parameters
39333933
----------------
3934-
showcaps : bool, default: True
3934+
showcaps : bool, default: :rc:`boxplot.showcaps`
39353935
Show the caps on the ends of whiskers.
3936-
showbox : bool, default: True
3936+
showbox : bool, default: :rc:`boxplot.showbox`
39373937
Show the central box.
3938-
showfliers : bool, default: True
3938+
showfliers : bool, default: :rc:`boxplot.showfliers`
39393939
Show the outliers beyond the caps.
3940-
showmeans : bool, default: False
3940+
showmeans : bool, default: :rc:`boxplot.showmeans`
39413941
Show the arithmetic means.
39423942
capprops : dict, default: None
39433943
The style of the caps.
@@ -3958,6 +3958,7 @@ def boxplot(self, x, notch=None, sym=None, vert=None, whis=None,
39583958
39593959
See Also
39603960
--------
3961+
.Axes.bxp : Draw a boxplot based on statistical parameters (instead of data).
39613962
violinplot : Draw an estimate of the probability density function.
39623963
"""
39633964

@@ -4086,13 +4087,26 @@ def bxp(self, bxpstats, positions=None, widths=None, vert=True,
40864087
meanline=False, manage_ticks=True, zorder=None,
40874088
capwidths=None):
40884089
"""
4089-
Drawing function for box and whisker plots.
4090+
Draw a box and whisker plot from statistical parameters.
4091+
4092+
The box extends from the first quartile *q1* to the third
4093+
quartile *q3* of the data, with a line at the median (*med*).
4094+
The whiskers extend from *whislow* to *whishi*.
4095+
Flier points are markers past the end of the whiskers.
4096+
See https://en.wikipedia.org/wiki/Box_plot for reference.
4097+
4098+
.. code-block:: none
4099+
4100+
whislow q1 med q3 whishi
4101+
|-----:-----|
4102+
o |--------| : |--------| o o
4103+
|-----:-----|
4104+
flier fliers
40904105
4091-
Make a box and whisker plot for each column of *x* or each
4092-
vector in sequence *x*. The box extends from the lower to
4093-
upper quartile values of the data, with a line at the median.
4094-
The whiskers extend from the box to show the range of the
4095-
data. Flier points are those past the end of the whiskers.
4106+
.. note::
4107+
This is a low-level drawing function for when you already
4108+
have the statistical parameters. If you want a boxplot based
4109+
on a dataset, use `~.Axes.boxplot` instead.
40964110
40974111
Parameters
40984112
----------
@@ -4172,9 +4186,9 @@ def bxp(self, bxpstats, positions=None, widths=None, vert=True,
41724186
- ``fliers``: points representing data beyond the whiskers (fliers).
41734187
- ``means``: points or lines representing the means.
41744188
4175-
Examples
4189+
See Also
41764190
--------
4177-
.. plot:: gallery/statistics/bxp.py
4191+
boxplot : Draw a boxplot based on data (instead of statistical parameters).
41784192
"""
41794193
# Clamp median line to edge of box by default.
41804194
medianprops = {
@@ -8278,6 +8292,11 @@ def violinplot(self, dataset, positions=None, vert=True, widths=0.5,
82788292
to identify the quantile values of each of the violin's
82798293
distribution.
82808294
8295+
See Also
8296+
--------
8297+
.Axes.violin :
8298+
Draw a violin plot based on statistical parameters (instead of data).
8299+
boxplot : Draw a box and whisker plot.
82818300
"""
82828301

82838302
def _kde_method(X, coords):
@@ -8298,7 +8317,7 @@ def _kde_method(X, coords):
82988317
def violin(self, vpstats, positions=None, vert=True, widths=0.5,
82998318
showmeans=False, showextrema=True, showmedians=False):
83008319
"""
8301-
Drawing function for violin plots.
8320+
Draw a violin plot from statistical parameters.
83028321
83038322
Draw a violin plot for each column of *vpstats*. Each filled area
83048323
extends to represent the entire data range, with optional lines at the
@@ -8380,6 +8399,10 @@ def violin(self, vpstats, positions=None, vert=True, widths=0.5,
83808399
- ``cquantiles``: A `~.collections.LineCollection` instance created
83818400
to identify the quantiles values of each of the violin's
83828401
distribution.
8402+
8403+
See Also
8404+
--------
8405+
violin : Draw a violin plot based on data (instead of statistical parameters).
83838406
"""
83848407

83858408
# Statistical quantities to be plotted on the violins

0 commit comments

Comments
 (0)