Seaborn is a data visualization library in Python that provides various functions for different charts and plots.
Refer Seaborn library in Python to learn more about seaborn.
A combination of the box and whisker plot is the same as the violin plot that displays the distribution of quantitative data over different levels of one or more categorical variables. The violin plot includes a kernel density estimation of the underlying distribution instead of a box plot, in which all plot elements correspond to real datapoints. This can be an efficient and appealing approach to display numerous data distributions at once.
seaborn.violinplot(x=None, y=None, hue=None, data=None, order=None, scale='area', gridsize=100, inner='box', orient=None, linewidth=None, color=None, palette=None)
x
, y
, hue
: These are inputs for plotting long-form data. These can be the names of the columns in the dataset.data
: This is the dataset to be referred for the inputs x
and y
. If x
and y
are omitted, this will be taken as wide-form data for plotting.order
: This is the order in which to plot the categorical levels in the dataset.scale
: This indicates the method used to scale the width of each violin. This parameter can have the following values:
area
: Every violin in the plot has the same area.count
: The width of the violins is proportional to the number of data points in the bin.width
: Every violin width will be the same.gridsize
: This indicates the number of data points in the grid used to compute the kernel density estimate.inner
: This parameter indicates the representation of the data points in the violin interior. This parameter can have the following values:
box
: This draws a boxplot.quartile
: This draws the quartiles of the distribution.point
or stick
: These show each underlying data point.None
: This draws unadorned violins.orient
: This is the orientation of the plot, for example, v
for vertical or h
for horizontal.linewidth
: This is the width of the gray lines on the plot frame.color
: This is the color to use for all of the elements.palette
: These are different colors to use for different levels.import seaborn as snsgeyser = sns.load_dataset("geyser")v_plot = sns.violinplot(x="kind", y="duration", data=geyser)fig = v_plot.get_figure()fig.savefig("output/plot.png")
seaborn
library.seaborn
library provides a predefined set of datasets. The different datasets can be found in seaborn datasets. One such dataset is the geyser dataset. The dataset is loaded into memory using the load_dataset()
function.violinplot()
function. Here, x
is the kind of volcanic eruption, and y
is the duration of the volcanic eruption.plot.png
.The plot above has inner
as box
(the default value). Hence, there’s a small boxplot in every violin.
import seaborn as snsgeyser = sns.load_dataset("geyser")v_plot = sns.violinplot(x="kind", y="duration", data=geyser, inner="stick")fig = v_plot.get_figure()fig.savefig("output/plot.png")
seaborn
library.seaborn
library provides a predefined set of datasets. The different datasets can be found in seaborn datasets. One such dataset is the geyser dataset. The dataset is loaded into memory using the load_dataset()
function.violinplot()
function. Here, x
is the kind of volcanic eruption, and y
is the duration of the volcanic eruption.plot.png
.The plot above has inner
as stick
(the default value). Hence, the data points are indicated as horizontal lines in each violin.
Free Resources