Participer au site avec un Tip
Rechercher
 

Améliorations / Corrections

Vous avez des améliorations (ou des corrections) à proposer pour ce document : je vous remerçie par avance de m'en faire part, cela m'aide à améliorer le site.

Emplacement :

Description des améliorations :

Vous êtes un professionnel et vous avez besoin d'une formation ? Sensibilisation à
l'Intelligence Artificielle
Voir le programme détaillé
Classe « Axes »

Méthode matplotlib.axes.Axes.boxplot

Signature de la méthode boxplot

def boxplot(self, x, *, notch=None, sym=None, vert=None, orientation='vertical', whis=None, positions=None, widths=None, patch_artist=None, bootstrap=None, usermedians=None, conf_intervals=None, meanline=None, showmeans=None, showcaps=None, showbox=None, showfliers=None, boxprops=None, tick_labels=None, flierprops=None, medianprops=None, meanprops=None, capprops=None, whiskerprops=None, manage_ticks=True, autorange=False, zorder=None, capwidths=None, label=None, data=None) 

Description

help(Axes.boxplot)

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 to the farthest data point
lying within 1.5x the inter-quartile range (IQR) from the box.
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


Parameters
----------
x : Array or a sequence of vectors.
    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: :rc:`boxplot.notch`
    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::

        In cases where the values of the CI are less than the
        lower quartile or greater than the upper quartile, the
        notches will extend beyond the box, giving it a
        distinctive "flipped" appearance. This is expected
        behavior and consistent with other statistical
        visualization packages.

sym : str, optional
    The default symbol for flier points.  An empty string ('') hides
    the fliers.  If `None`, then the fliers default to 'b+'.  More
    control is provided by the *flierprops* parameter.

vert : bool, optional
    .. deprecated:: 3.11
        Use *orientation* instead.

        This is a pending deprecation for 3.10, with full deprecation
        in 3.11 and removal in 3.13.
        If this is given during the deprecation period, it overrides
        the *orientation* parameter.

    If True, plots the boxes vertically.
    If False, plots the boxes horizontally.

orientation : {'vertical', 'horizontal'}, default: 'vertical'
    If 'horizontal', plots the boxes horizontally.
    Otherwise, plots the boxes vertically.

    .. versionadded:: 3.10

whis : float or (float, float), default: 1.5
    The position of the whiskers.

    If a float, the lower whisker is at the lowest datum above
    ``Q1 - whis*(Q3-Q1)``, and the upper whisker at the highest datum
    below ``Q3 + whis*(Q3-Q1)``, where Q1 and Q3 are the first and
    third quartiles.  The default value of ``whis = 1.5`` corresponds
    to Tukey's original definition of boxplots.

    If a pair of floats, they indicate the percentiles at which to
    draw the whiskers (e.g., (5, 95)).  In particular, setting this to
    (0, 100) results in whiskers covering the whole range of the data.

    In the edge case where ``Q1 == Q3``, *whis* is automatically set
    to (0, 100) (cover the whole range of the data) if *autorange* is
    True.

    Beyond the whiskers, data are considered outliers and are plotted
    as individual points.

bootstrap : int, optional
    Specifies whether to bootstrap the confidence intervals
    around the median for notched boxplots. If *bootstrap* is
    None, no bootstrapping is performed, and notches are
    calculated using a Gaussian-based asymptotic approximation
    (see McGill, R., Tukey, J.W., and Larsen, W.A., 1978, and
    Kendall and Stuart, 1967). Otherwise, bootstrap specifies
    the number of times to bootstrap the median to determine its
    95% confidence intervals. Values between 1000 and 10000 are
    recommended.

usermedians : 1D array-like, optional
    A 1D array-like of length ``len(x)``.  Each entry that is not
    `None` forces the value of the median for the corresponding
    dataset.  For entries that are `None`, the medians are computed
    by Matplotlib as normal.

conf_intervals : array-like, optional
    A 2D array-like of shape ``(len(x), 2)``.  Each entry that is not
    None forces the location of the corresponding notch (which is
    only drawn if *notch* is `True`).  For entries that are `None`,
    the notches are computed by the method specified by the other
    parameters (e.g., *bootstrap*).

positions : array-like, optional
    The positions of the boxes. The ticks and limits are
    automatically set to match the positions. Defaults to
    ``range(1, N+1)`` where N is the number of boxes to be drawn.

widths : float or array-like
    The widths of the boxes.  The default is 0.5, or ``0.15*(distance
    between extreme positions)``, if that is smaller.

patch_artist : bool, default: :rc:`boxplot.patchartist`
    If `False` produces boxes with the Line2D artist. Otherwise,
    boxes are drawn with Patch artists.

tick_labels : list of str, optional
    The tick labels of each boxplot.
    Ticks are always placed at the box *positions*. If *tick_labels* is given,
    the ticks are labelled accordingly. Otherwise, they keep their numeric
    values.

    .. versionchanged:: 3.9
        Renamed from *labels*, which is deprecated since 3.9
        and will be removed in 3.11.

manage_ticks : bool, default: True
    If True, the tick locations and labels will be adjusted to match
    the boxplot positions.

autorange : bool, default: False
    When `True` and the data are distributed such that the 25th and
    75th percentiles are equal, *whis* is set to (0, 100) such
    that the whisker ends are at the minimum and maximum of the data.

meanline : bool, default: :rc:`boxplot.meanline`
    If `True` (and *showmeans* is `True`), will try to render the
    mean as a line spanning the full width of the box according to
    *meanprops* (see below).  Not recommended if *shownotches* is also
    True.  Otherwise, means will be shown as points.

zorder : float, default: ``Line2D.zorder = 2``
    The zorder of the boxplot.

Returns
-------
dict
  A dictionary mapping each component of the boxplot to a list
  of the `.Line2D` instances created. That dictionary has the
  following keys (assuming vertical boxplots):

  - ``boxes``: the main body of the boxplot showing the
    quartiles and the median's confidence intervals if
    enabled.

  - ``medians``: horizontal lines at the median of each box.

  - ``whiskers``: the vertical lines extending to the most
    extreme, non-outlier data points.

  - ``caps``: the horizontal lines at the ends of the
    whiskers.

  - ``fliers``: points representing data that extend beyond
    the whiskers (fliers).

  - ``means``: points or lines representing the means.

Other Parameters
----------------
showcaps : bool, default: :rc:`boxplot.showcaps`
    Show the caps on the ends of whiskers.
showbox : bool, default: :rc:`boxplot.showbox`
    Show the central box.
showfliers : bool, default: :rc:`boxplot.showfliers`
    Show the outliers beyond the caps.
showmeans : bool, default: :rc:`boxplot.showmeans`
    Show the arithmetic means.
capprops : dict, default: None
    The style of the caps.
capwidths : float or array, default: None
    The widths of the caps.
boxprops : dict, default: None
    The style of the box.
whiskerprops : dict, default: None
    The style of the whiskers.
flierprops : dict, default: None
    The style of the fliers.
medianprops : dict, default: None
    The style of the median.
meanprops : dict, default: None
    The style of the mean.
label : str or list of str, optional
    Legend labels. Use a single string when all boxes have the same style and
    you only want a single legend entry for them. Use a list of strings to
    label all boxes individually. To be distinguishable, the boxes should be
    styled individually, which is currently only possible by modifying the
    returned artists, see e.g. :doc:`/gallery/statistics/boxplot_demo`.

    In the case of a single string, the legend entry will technically be
    associated with the first box only. By default, the legend will show the
    median line (``result["medians"]``); if *patch_artist* is True, the legend
    will show the box `.Patch` artists (``result["boxes"]``) instead.

    .. versionadded:: 3.9

data : indexable object, optional
    If given, all parameters also accept a string ``s``, which is
    interpreted as ``data[s]`` if ``s`` is a key in ``data``.

See Also
--------
.Axes.bxp : Draw a boxplot from pre-computed statistics.
violinplot : Draw an estimate of the probability density function.


Vous êtes un professionnel et vous avez besoin d'une formation ? Mise en oeuvre d'IHM
avec Qt et PySide6
Voir le programme détaillé