Skip to content

Commit dae7d77

Browse files
timhoffmdstansby
andcommitted
DOC: Update violinplot() docs
Some corrections and small rewrites. Co-authored-by: David Stansby <[email protected]>
1 parent 810a43b commit dae7d77

File tree

2 files changed

+28
-31
lines changed

2 files changed

+28
-31
lines changed

Diff for: lib/matplotlib/axes/_axes.py

+24-26
Original file line numberDiff line numberDiff line change
@@ -8206,43 +8206,41 @@ def violinplot(self, dataset, positions=None, vert=True, widths=0.5,
82068206
The input data.
82078207
82088208
positions : array-like, default: [1, 2, ..., n]
8209-
The positions of the violins. The ticks and limits are
8210-
automatically set to match the positions.
8209+
The positions of the violins; i.e. coordinates on the x-axis for
8210+
vertical violins (or y-axis for horizontal violins).
82118211
82128212
vert : bool, default: True.
82138213
If true, creates a vertical violin plot.
82148214
Otherwise, creates a horizontal violin plot.
82158215
8216-
widths : array-like, default: 0.5
8217-
Either a scalar or a vector that sets the maximal width of
8218-
each violin. The default is 0.5, which uses about half of the
8219-
available horizontal space.
8216+
widths : float or array-like, default: 0.5
8217+
The maximum width of each violin in units of the *positions* axis.
8218+
The default is 0.5, which is half the available space when using default
8219+
*positions*.
82208220
82218221
showmeans : bool, default: False
8222-
If `True`, will toggle rendering of the means.
8222+
Whether to show the mean with a line.
82238223
82248224
showextrema : bool, default: True
8225-
If `True`, will toggle rendering of the extrema.
8225+
Whether to show extrema with a line.
82268226
82278227
showmedians : bool, default: False
8228-
If `True`, will toggle rendering of the medians.
8228+
Whether to show the median with a line.
82298229
82308230
quantiles : array-like, default: None
82318231
If not None, set a list of floats in interval [0, 1] for each violin,
82328232
which stands for the quantiles that will be rendered for that
82338233
violin.
82348234
82358235
points : int, default: 100
8236-
Defines the number of points to evaluate each of the
8237-
gaussian kernel density estimations at.
8236+
The number of points to evaluate each of the gaussian kernel density
8237+
estimations at.
82388238
8239-
bw_method : str, scalar or callable, optional
8240-
The method used to calculate the estimator bandwidth. This can be
8241-
'scott', 'silverman', a scalar constant or a callable. If a
8242-
scalar, this will be used directly as `kde.factor`. If a
8239+
bw_method : {'scott', 'silverman'} or float or callable, default: 'scott'
8240+
The method used to calculate the estimator bandwidth. If a
8241+
float, this will be used directly as `kde.factor`. If a
82438242
callable, it should take a `matplotlib.mlab.GaussianKDE` instance as
8244-
its only parameter and return a scalar. If None (default), 'scott'
8245-
is used.
8243+
its only parameter and return a float.
82468244
82478245
data : indexable object, optional
82488246
DATA_PARAMETER_PLACEHOLDER
@@ -8329,26 +8327,26 @@ def violin(self, vpstats, positions=None, vert=True, widths=0.5,
83298327
for this violin's dataset.
83308328
83318329
positions : array-like, default: [1, 2, ..., n]
8332-
The positions of the violins. The ticks and limits are
8333-
automatically set to match the positions.
8330+
The positions of the violins; i.e. coordinates on the x-axis for
8331+
vertical violins (or y-axis for horizontal violins).
83348332
83358333
vert : bool, default: True.
83368334
If true, plots the violins vertically.
83378335
Otherwise, plots the violins horizontally.
83388336
8339-
widths : array-like, default: 0.5
8340-
Either a scalar or a vector that sets the maximal width of
8341-
each violin. The default is 0.5, which uses about half of the
8342-
available horizontal space.
8337+
widths : float or array-like, default: 0.5
8338+
The maximum width of each violin in units of the *positions* axis.
8339+
The default is 0.5, which is half available space when using default
8340+
*positions*.
83438341
83448342
showmeans : bool, default: False
8345-
If true, will toggle rendering of the means.
8343+
Whether to show the mean with a line.
83468344
83478345
showextrema : bool, default: True
8348-
If true, will toggle rendering of the extrema.
8346+
Whether to show extrema with a line.
83498347
83508348
showmedians : bool, default: False
8351-
If true, will toggle rendering of the medians.
8349+
Whether to show the median with a line.
83528350
83538351
Returns
83548352
-------

Diff for: lib/matplotlib/mlab.py

+4-5
Original file line numberDiff line numberDiff line change
@@ -776,12 +776,11 @@ class GaussianKDE:
776776
dataset : array-like
777777
Datapoints to estimate from. In case of univariate data this is a 1-D
778778
array, otherwise a 2D array with shape (# of dims, # of data).
779-
bw_method : str, scalar or callable, optional
780-
The method used to calculate the estimator bandwidth. This can be
781-
'scott', 'silverman', a scalar constant or a callable. If a
782-
scalar, this will be used directly as `kde.factor`. If a
779+
bw_method : {'scott', 'silverman'} or float or callable, optional
780+
The method used to calculate the estimator bandwidth. If a
781+
float, this will be used directly as `kde.factor`. If a
783782
callable, it should take a `GaussianKDE` instance as only
784-
parameter and return a scalar. If None (default), 'scott' is used.
783+
parameter and return a float. If None (default), 'scott' is used.
785784
786785
Attributes
787786
----------

0 commit comments

Comments
 (0)