Skip to content

Commit e4e6840

Browse files
authored
Merge pull request #27787 from timhoffm/boxplot-doc
Improve documentation on boxplot and violinplot
2 parents 2a2ab56 + 3f1d8be commit e4e6840

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
@@ -3897,7 +3897,7 @@ def boxplot(self, x, notch=None, sym=None, vert=None, whis=None,
38973897
75th percentiles are equal, *whis* is set to (0, 100) such
38983898
that the whisker ends are at the minimum and maximum of the data.
38993899
3900-
meanline : bool, default: False
3900+
meanline : bool, default: :rc:`boxplot.meanline`
39013901
If `True` (and *showmeans* is `True`), will try to render the
39023902
mean as a line spanning the full width of the box according to
39033903
*meanprops* (see below). Not recommended if *shownotches* is also
@@ -3932,13 +3932,13 @@ def boxplot(self, x, notch=None, sym=None, vert=None, whis=None,
39323932
39333933
Other Parameters
39343934
----------------
3935-
showcaps : bool, default: True
3935+
showcaps : bool, default: :rc:`boxplot.showcaps`
39363936
Show the caps on the ends of whiskers.
3937-
showbox : bool, default: True
3937+
showbox : bool, default: :rc:`boxplot.showbox`
39383938
Show the central box.
3939-
showfliers : bool, default: True
3939+
showfliers : bool, default: :rc:`boxplot.showfliers`
39403940
Show the outliers beyond the caps.
3941-
showmeans : bool, default: False
3941+
showmeans : bool, default: :rc:`boxplot.showmeans`
39423942
Show the arithmetic means.
39433943
capprops : dict, default: None
39443944
The style of the caps.
@@ -3959,6 +3959,7 @@ def boxplot(self, x, notch=None, sym=None, vert=None, whis=None,
39593959
39603960
See Also
39613961
--------
3962+
.Axes.bxp : Draw a boxplot from pre-computed statistics.
39623963
violinplot : Draw an estimate of the probability density function.
39633964
"""
39643965

@@ -4084,13 +4085,26 @@ def bxp(self, bxpstats, positions=None, widths=None, vert=True,
40844085
meanline=False, manage_ticks=True, zorder=None,
40854086
capwidths=None):
40864087
"""
4087-
Drawing function for box and whisker plots.
4088+
Draw a box and whisker plot from pre-computed statistics.
4089+
4090+
The box extends from the first quartile *q1* to the third
4091+
quartile *q3* of the data, with a line at the median (*med*).
4092+
The whiskers extend from *whislow* to *whishi*.
4093+
Flier points are markers past the end of the whiskers.
4094+
See https://en.wikipedia.org/wiki/Box_plot for reference.
4095+
4096+
.. code-block:: none
4097+
4098+
whislow q1 med q3 whishi
4099+
|-----:-----|
4100+
o |--------| : |--------| o o
4101+
|-----:-----|
4102+
flier fliers
40884103
4089-
Make a box and whisker plot for each column of *x* or each
4090-
vector in sequence *x*. The box extends from the lower to
4091-
upper quartile values of the data, with a line at the median.
4092-
The whiskers extend from the box to show the range of the
4093-
data. Flier points are those past the end of the whiskers.
4104+
.. note::
4105+
This is a low-level drawing function for when you already
4106+
have the statistical parameters. If you want a boxplot based
4107+
on a dataset, use `~.Axes.boxplot` instead.
40944108
40954109
Parameters
40964110
----------
@@ -4170,9 +4184,9 @@ def bxp(self, bxpstats, positions=None, widths=None, vert=True,
41704184
- ``fliers``: points representing data beyond the whiskers (fliers).
41714185
- ``means``: points or lines representing the means.
41724186
4173-
Examples
4187+
See Also
41744188
--------
4175-
.. plot:: gallery/statistics/bxp.py
4189+
boxplot : Draw a boxplot from data instead of pre-computed statistics.
41764190
"""
41774191
# Clamp median line to edge of box by default.
41784192
medianprops = {
@@ -8276,6 +8290,10 @@ def violinplot(self, dataset, positions=None, vert=True, widths=0.5,
82768290
to identify the quantile values of each of the violin's
82778291
distribution.
82788292
8293+
See Also
8294+
--------
8295+
.Axes.violin : Draw a violin from pre-computed statistics.
8296+
boxplot : Draw a box and whisker plot.
82798297
"""
82808298

82818299
def _kde_method(X, coords):
@@ -8296,7 +8314,7 @@ def _kde_method(X, coords):
82968314
def violin(self, vpstats, positions=None, vert=True, widths=0.5,
82978315
showmeans=False, showextrema=True, showmedians=False):
82988316
"""
8299-
Drawing function for violin plots.
8317+
Draw a violin plot from pre-computed statistics.
83008318
83018319
Draw a violin plot for each column of *vpstats*. Each filled area
83028320
extends to represent the entire data range, with optional lines at the
@@ -8378,6 +8396,11 @@ def violin(self, vpstats, positions=None, vert=True, widths=0.5,
83788396
- ``cquantiles``: A `~.collections.LineCollection` instance created
83798397
to identify the quantiles values of each of the violin's
83808398
distribution.
8399+
8400+
See Also
8401+
--------
8402+
violin :
8403+
Draw a violin plot from data instead of pre-computed statistics.
83818404
"""
83828405

83838406
# Statistical quantities to be plotted on the violins

0 commit comments

Comments
 (0)