Seaborn is a library mostly used for statistical plotting in Python. It is built on top of Matplotlib and provides beautiful default styles and color palettes to make statistical plots more attractive.
Seaborn is an amazing visualization library for statistical graphics plotting in Python. It provides beautiful default styles and color palettes to make statistical plots more attractive. It is built on the top of matplotlib library
and also closely integrated to the data structures from pandas.
Different categories of plot in Seaborn
Plots are basically used for visualizing the relationship between variables. Those variables can be either
be completely numerical or a category like a group, class or division. Seaborn divides plot into the below categories –
Relational plots: This plot is used to understand the relation between two variables.
Categorical plots: This plot deals with categorical variables and how they can be visualized.
Distribution plots: This plot is used for examining univariate and bivariate distributions
Regression plots: The
regression plots in seaborn are primarily intended to add a visual guide that helps to emphasize patterns in a dataset during exploratory data analyses.
Matrix plots: A matrix plot is an array of scatterplots.
Multi-plot grids: It is an useful approach is to draw multiple instances of the same plot on different subsets of the dataset.
pip install seaborn
Seaborn dist plot is used to plot a histogram, with some other variations like kdeplot and rugplot.
# Plot a simple histogram and kde
# with binsize determined automatically
sns.distplot(d, kde=True, color="m")
The line plot is one of the most basic plot in seaborn library. This plot is mainly used to visualize the data in form of some time series, i.e. in continuous manner.
# Plot the responses for different
# events and regions
sns.lineplot(x="timepoint",y="signal",hue="region", style="event", data=fmri)
The lmplot is another most basic plot. It shows a line representing a linear regression model along with data points on the 2D-space and x and y can be set as the horizontal and vertical labels respectively.
# Show the results of a linear regression
sns.lmplot(x="x", y="y", data=df)
sns.set(style=" ")
ax = sns.swarmplot(x=' ', y=' ', data=df )
plt.title(' ');
plt.show()
sns.barplot(x =' ', y =' ', data = df,
palette ='plasma')
sns.countplot(x ='sex', data = df)
sns.boxplot(x=' ', y=' ', data=df, hue='')
sns.violinplot(x='', y='', data=df,hue='', split=True)
sns.stripplot(x=' ', y=' ', data=df,jitter=True, hue=' ', dodge=True)
sns.set_style('white')
sns.despine()
plt.figure(figsize =(12, 3))
sns.set_context('poster', font_scale = 2)
Syntax: seaborn.color_palette(palette=None, n_colors=None, desat=None)
Parameters:
palette: Name of palette or None to return current palette.
n_colors: Number of colors in the palette.
desat: Proportion to desaturate each color.
Returns: list of RGB tuples or matplotlib.colors.Colormap
types:
current_palette = sns.color_palette()
sns.palplot(current_palette)
plt.show()
current_palette = sns.color_palette()
sns.palplot(current_palette)
plt.show()
current_palette = sns.color_palette()
sns.palplot(sns.color_palette("terrain_r", 7))
plt.show()