matplotlib.axes.Axes.violin¶
-
Axes.
violin
(vpstats, positions=None, vert=True, widths=0.5, showmeans=False, showextrema=True, showmedians=False)[source]¶ Drawing function for violin plots.
Draw a violin plot for each column of vpstats. Each filled area extends to represent the entire data range, with optional lines at the mean, the median, the minimum, the maximum, and the quantiles values.
Parameters: - vpstatslist of dicts
A list of dictionaries containing stats for each violin plot. Required keys are:
coords
: A list of scalars containing the coordinates that the violin's kernel density estimate were evaluated at.vals
: A list of scalars containing the values of the kernel density estimate at each of the coordinates given in coords.mean
: The mean value for this violin's dataset.median
: The median value for this violin's dataset.min
: The minimum value for this violin's dataset.max
: The maximum value for this violin's dataset.
Optional keys are:
quantiles
: A list of scalars containing the quantile values for this violin's dataset.
- positionsarray-like, default: [1, 2, ..., n]
Sets the positions of the violins. The ticks and limits are automatically set to match the positions.
- vertbool, default: True.
If true, plots the violins vertically. Otherwise, plots the violins horizontally.
- widthsarray-like, default: 0.5
Either a scalar or a vector that sets the maximal width of each violin. The default is 0.5, which uses about half of the available horizontal space.
- showmeansbool, default: False
If true, will toggle rendering of the means.
- showextremabool, default: True
If true, will toggle rendering of the extrema.
- showmediansbool, default: False
If true, will toggle rendering of the medians.
Returns: - dict
A dictionary mapping each component of the violinplot to a list of the corresponding collection instances created. The dictionary has the following keys:
bodies
: A list of thePolyCollection
instances containing the filled area of each violin.cmeans
: ALineCollection
instance that marks the mean values of each of the violin's distribution.cmins
: ALineCollection
instance that marks the bottom of each violin's distribution.cmaxes
: ALineCollection
instance that marks the top of each violin's distribution.cbars
: ALineCollection
instance that marks the centers of each violin's distribution.cmedians
: ALineCollection
instance that marks the median values of each of the violin's distribution.cquantiles
: ALineCollection
instance created to identify the quantiles values of each of the violin's distribution.