Seaborn Basic Plots
Seaborn Basic Plots
#seaborn
Table of Contents
About 1
Remarks 2
Examples 2
Installation or Setup 2
Chapter 2: Barplot 3
Examples 3
Introduction 5
Examples 5
Credits 7
About
You can share this PDF with anyone you feel could benefit from it, downloaded the latest version
from: seaborn
It is an unofficial and free seaborn ebook created for educational purposes. All the content is
extracted from Stack Overflow Documentation, which is written by many hardworking individuals at
Stack Overflow. It is neither affiliated with Stack Overflow nor official seaborn.
The content is released under Creative Commons BY-SA, and the list of contributors to each
chapter are provided in the credits section at the end of this book. Images may be copyright of
their respective owners unless otherwise specified. All trademarks and registered trademarks are
the property of their respective company owners.
Use the content presented in this book at your own risk; it is not guaranteed to be correct nor
accurate, please send your feedback and corrections to [email protected]
https://riptutorial.com/ 1
Chapter 1: Getting started with seaborn
Remarks
This section provides an overview of what seaborn is, and why a developer might want to use it.
It should also mention any large subjects within seaborn, and link out to the related topics. Since
the Documentation for seaborn is new, you may need to create initial versions of those related
topics.
Examples
Installation or Setup
https://riptutorial.com/ 2
Chapter 2: Barplot
Examples
Barplot with Gradient
df = pd.DataFrame({'a':[1,2,3,4,5], 'b':[10,5,2,4,5]})
using seaborn:
then you can also play with the palette option and colormap adding a gradient according to some
data like:
https://riptutorial.com/ 3
sns.barplot(df['a'], df['b'], palette=cm.Blues(df['b']*10)
obtaining:
https://riptutorial.com/ 4
Chapter 3: Correlation plot
Introduction
A correlation plot can be regarded as a subcategory of heatmaps. An out-of-the box seaborn
heatmap shows the correlation between two variables twice. A correlation plot should handle
duplicated values by masking parts of the map, and / or let the masked part show values instead
of colors. A bar chart should also be included.
Examples
Basic correlation plot
import pandas as pd
import seaborn as sns
import numpy as np
# Compute correlations
corr = df.corr()
https://riptutorial.com/ 5
Possible improvements:
https://riptutorial.com/ 6
Credits
S.
Chapters Contributors
No
https://riptutorial.com/ 7