Skip to content

Commit 5858cad

Browse files
authored
Merge pull request #19866 from anntzer/ba
Switch to asciiart for boxplot illustration.
2 parents a72ec07 + 2951083 commit 5858cad

File tree

2 files changed

+28
-35
lines changed

2 files changed

+28
-35
lines changed

doc/_static/boxplot_explanation.png

-238 KB
Binary file not shown.

lib/matplotlib/axes/_axes.py

+28-35
Original file line numberDiff line numberDiff line change
@@ -3536,26 +3536,38 @@ def boxplot(self, x, notch=None, sym=None, vert=None, whis=None,
35363536
meanprops=None, capprops=None, whiskerprops=None,
35373537
manage_ticks=True, autorange=False, zorder=None):
35383538
"""
3539-
Make a box and whisker plot.
3539+
Draw a box and whisker plot.
3540+
3541+
The box extends from the first quartile (Q1) to the third
3542+
quartile (Q3) of the data, with a line at the median. The
3543+
whiskers extend from the box by 1.5x the inter-quartile range
3544+
(IQR). Flier points are those past the end of the whiskers.
3545+
See https://en.wikipedia.org/wiki/Box_plot for reference.
3546+
3547+
.. code-block:: none
3548+
3549+
Q1-1.5IQR Q1 median Q3 Q3+1.5IQR
3550+
|-----:-----|
3551+
o |--------| : |--------| o o
3552+
|-----:-----|
3553+
flier <-----------> fliers
3554+
IQR
35403555
3541-
Make a box and whisker plot for each column of *x* or each
3542-
vector in sequence *x*. The box extends from the lower to
3543-
upper quartile values of the data, with a line at the median.
3544-
The whiskers extend from the box to show the range of the
3545-
data. Flier points are those past the end of the whiskers.
35463556
35473557
Parameters
35483558
----------
35493559
x : Array or a sequence of vectors.
3550-
The input data.
3560+
The input data. If a 2D array, a boxplot is drawn for each column
3561+
in *x*. If a sequence of 1D arrays, a boxplot is drawn for each
3562+
array in *x*.
35513563
35523564
notch : bool, default: False
3553-
Whether to draw a notched box plot (`True`), or a rectangular box
3554-
plot (`False`). The notches represent the confidence interval (CI)
3555-
around the median. The documentation for *bootstrap* describes how
3556-
the locations of the notches are computed by default, but their
3557-
locations may also be overridden by setting the *conf_intervals*
3558-
parameter.
3565+
Whether to draw a notched boxplot (`True`), or a rectangular
3566+
boxplot (`False`). The notches represent the confidence interval
3567+
(CI) around the median. The documentation for *bootstrap*
3568+
describes how the locations of the notches are computed by
3569+
default, but their locations may also be overridden by setting the
3570+
*conf_intervals* parameter.
35593571
35603572
.. note::
35613573
@@ -3700,28 +3712,9 @@ def boxplot(self, x, notch=None, sym=None, vert=None, whis=None,
37003712
meanprops : dict, default: None
37013713
The style of the mean.
37023714
3703-
Notes
3704-
-----
3705-
Box plots provide insight into distribution properties of the data.
3706-
However, they can be challenging to interpret for the unfamiliar
3707-
reader. The figure below illustrates the different visual features of
3708-
a box plot.
3709-
3710-
.. image:: /_static/boxplot_explanation.png
3711-
:alt: Illustration of box plot features
3712-
:scale: 50 %
3713-
3714-
The whiskers mark the range of the non-outlier data. The most common
3715-
definition of non-outlier is ``[Q1 - 1.5xIQR, Q3 + 1.5xIQR]``, which
3716-
is also the default in this function. Other whisker meanings can be
3717-
applied via the *whis* parameter.
3718-
3719-
See `Box plot <https://en.wikipedia.org/wiki/Box_plot>`_ on Wikipedia
3720-
for further information.
3721-
3722-
Violin plots (`~.Axes.violinplot`) add even more detail about the
3723-
statistical distribution by plotting the kernel density estimation
3724-
(KDE) as an estimation of the probability density function.
3715+
See Also
3716+
--------
3717+
violinplot : Draw an estimate of the probability density function.
37253718
"""
37263719

37273720
# Missing arguments default to rcParams.

0 commit comments

Comments
 (0)