Trusted answers to developer questions
Trusted Answers to Developer Questions

Related Tags

python
seaborn
graphs
charts

Seaborn library in Python

Educative Answers Team

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.

Installing Seaborn

To install the latest release of seaborn, you can use pip:

pip install seaborn

Data Visualization using Seaborn

We will now go through some of the plots that seaborn offers and the code that can be used to make these plots.

Density plots of variables

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")
widget

Scatterplot

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)
widget

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.

RELATED TAGS

python
seaborn
graphs
charts
Copyright ©2022 Educative, Inc. All rights reserved
RELATED COURSES

View all Courses

Keep Exploring