Matplotlib is a plotting library for creating static, animated, and interactive visualizations in Python. Matplotlib can be used in Python scripts, the Python and IPython shell, web application servers, and various graphical user interface toolkits like Tkinter, awxPython, etc.
Note: For more information, refer to Python Matplotlib – An Overview
What does a violin plot signify ?
Violin plots are a combination of box plot and histograms. It portrays the distribution, median, interquartile range of data. So we see that iqr and median are the statistical information provided by box plot whereas distribution is being provided by the histogram.
- The white dot refers to the median.
- The end points of the bold line represent the iqr1 and iqr3.
- The end points of the thin line represent the min and max similar to the box plot.
- The distribution above 1.5x interquartile(min, max end points of the thin line) denotes the presence of outliers.
Syntax: violinplot(dataset, positions=None, vert=True, widths=0.5, showmeans=False, showextrema=True, showmedians=False, quantiles=None, points=100,
bw_method=None, *, data=None)
dataset: Array or a sequence of vectors.
The input data.
positions: array-like, default = [1, 2, …, n].
Sets the positions of the violins. The ticks and limits are automatically set to match the positions.
vert: bool, default = True.
If true, creates a vertical violin plot. Otherwise, creates a horizontal violin plot.
widths: array-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.
showmeans: bool, default = False
If True, will toggle rendering of the means.
showextrema: bool, default = True
If True, will toggle rendering of the extrema.
showmedians: bool, default = False
If True, will toggle rendering of the medians.
quantiles: array-like, default = None
If not None, set a list of floats in interval [0, 1] for each violin, which stands for the quantiles that will be rendered for that violin.
points: scalar, default = 100
Defines the number of points to evaluate each of the gaussian kernel density estimations at.
bw_method: str, scalar or callable, optional
The method used to calculate the estimator bandwidth. This can be ‘scott’, ‘silverman’, a scalar constant or a callable. If a scalar, this will be used directly as kde.factor. If a callable, it should take a GaussianKDE instance as its only parameter and return a scalar. If None (default), ‘scott’ is used.
Example 2: Multiple Violin plots
- Violin Plot for Data Analysis
- Box Plot in Python using Matplotlib
- Contour Plot using Matplotlib - Python
- Plot a pie chart in Python using Matplotlib
- Tri-Surface Plot in Python using Matplotlib
- Simple Plot in Python using Matplotlib
- Plot 2-D Histogram in Python using Matplotlib
- Make an area plot in Python using Bokeh
- Plot the magnitude spectrum in Python using Matplotlib
- Matplotlib.pyplot.plot() function in Python
- Plot a quadrilateral mesh in Python using Matplotlib
- Plot Mathematical Expressions in Python using Matplotlib
- Plot the phase spectrum in Python using Matplotlib
- Plot the power spectral density using Matplotlib - Python
- Create a pseudocolor plot of an unstructured triangular grid in Python using Matplotlib
- Matplotlib.axes.Axes.plot() in Python
- Bar Plot in Matplotlib
- Autocorrelation plot using Matplotlib
- Quiver Plot in Matplotlib
- Make filled polygons between two curves in Python using Matplotlib
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to email@example.com. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.