Seaborn is an amazing Python visualization library built on top of matplotlib
that provides a high-level interface for drawing attractive and informative statistical graphics.
To install the latest release of seaborn, you can use pip
:
pip install seaborn
We will now go through some of the plots that seaborn offers and the code that can be used to make these plots.
Kdeplot allows us to plot the distribution of several variables on the same plot so that they can be compared. The code for this is:
# library and dataset
import seaborn as sns
df = sns.load_dataset('iris')
# plot of 2 variables
p1=sns.kdeplot(df['sepal_width'], shade=True, color="r")
p1=sns.kdeplot(df['sepal_length'], shade=True, color="b")
A scatterplot is used to visualize relationships between two variables. Each dot represents an observation in the dataset. The code to plot this graph is given below. Views
and Upvotes
are numerical fields in our df
data frame.
sns.relplot(x="Views", y="Upvotes", data = df)
These are the codes for just two of the many plots we can make using Seaborn. Details on other types of plots can be found in the official documentation page.