Skip to content

Switch to asciiart for boxplot illustration. #19866

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Apr 9, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file removed doc/_static/boxplot_explanation.png
Binary file not shown.
63 changes: 28 additions & 35 deletions lib/matplotlib/axes/_axes.py
Original file line number Diff line number Diff line change
Expand Up @@ -3550,26 +3550,38 @@ def boxplot(self, x, notch=None, sym=None, vert=None, whis=None,
meanprops=None, capprops=None, whiskerprops=None,
manage_ticks=True, autorange=False, zorder=None):
"""
Make a box and whisker plot.
Draw a box and whisker plot.

The box extends from the first quartile (Q1) to the third
quartile (Q3) of the data, with a line at the median. The
whiskers extend from the box by 1.5x the inter-quartile range
(IQR). Flier points are those past the end of the whiskers.
See https://en.wikipedia.org/wiki/Box_plot for reference.

.. code-block:: none

Q1-1.5IQR Q1 median Q3 Q3+1.5IQR
|-----:-----|
o |--------| : |--------| o o
|-----:-----|
flier <-----------> fliers
IQR

Make a box and whisker plot for each column of *x* or each
vector in sequence *x*. The box extends from the lower to
upper quartile values of the data, with a line at the median.
The whiskers extend from the box to show the range of the
data. Flier points are those past the end of the whiskers.

Parameters
----------
x : Array or a sequence of vectors.
The input data.
The input data. If a 2D array, a boxplot is drawn for each column
in *x*. If a sequence of 1D arrays, a boxplot is drawn for each
array in *x*.

notch : bool, default: False
Whether to draw a notched box plot (`True`), or a rectangular box
plot (`False`). The notches represent the confidence interval (CI)
around the median. The documentation for *bootstrap* describes how
the locations of the notches are computed by default, but their
locations may also be overridden by setting the *conf_intervals*
parameter.
Whether to draw a notched boxplot (`True`), or a rectangular
boxplot (`False`). The notches represent the confidence interval
(CI) around the median. The documentation for *bootstrap*
describes how the locations of the notches are computed by
default, but their locations may also be overridden by setting the
*conf_intervals* parameter.

.. note::

Expand Down Expand Up @@ -3714,28 +3726,9 @@ def boxplot(self, x, notch=None, sym=None, vert=None, whis=None,
meanprops : dict, default: None
The style of the mean.

Notes
-----
Box plots provide insight into distribution properties of the data.
However, they can be challenging to interpret for the unfamiliar
reader. The figure below illustrates the different visual features of
a box plot.

.. image:: /_static/boxplot_explanation.png
:alt: Illustration of box plot features
:scale: 50 %

The whiskers mark the range of the non-outlier data. The most common
definition of non-outlier is ``[Q1 - 1.5xIQR, Q3 + 1.5xIQR]``, which
is also the default in this function. Other whisker meanings can be
applied via the *whis* parameter.

See `Box plot <https://en.wikipedia.org/wiki/Box_plot>`_ on Wikipedia
for further information.

Violin plots (`~.Axes.violinplot`) add even more detail about the
statistical distribution by plotting the kernel density estimation
(KDE) as an estimation of the probability density function.
See Also
--------
violinplot : Draw an estimate of the probability density function.
"""

# Missing arguments default to rcParams.
Expand Down