SlideShare a Scribd company logo
PythonForDataScience Cheat Sheet
Seaborn
Learn Data Science Interactively at www.DataCamp.com
Statistical Data Visualization With Seaborn
DataCamp
Learn Python for Data Science Interactively
Figure Aesthetics
Data
The Python visualization library Seaborn is based on
matplotlib and provides a high-level interface for drawing
attractive statistical graphics.
Make use of the following aliases to import the libraries:
The basic steps to creating plots with Seaborn are:
1. Prepare some data
2. Control figure aesthetics
3. Plot with Seaborn
4. Further customize your plot
>>> import pandas as pd
>>> import numpy as np
>>> uniform_data = np.random.rand(10, 12)
>>> data = pd.DataFrame({'x':np.arange(1,101),
'y':np.random.normal(0,4,100)})
>>> import matplotlib.pyplot as plt
>>> import seaborn as sns
Plotting With Seaborn
>>> import matplotlib.pyplot as plt
>>> import seaborn as sns
>>> tips = sns.load_dataset("tips")
>>> sns.set_style("whitegrid")
>>> g = sns.lmplot(x="tip",
y="total_bill",
data=tips,
aspect=2)
>>> g = (g.set_axis_labels("Tip","Total bill(USD)").
set(xlim=(0,10),ylim=(0,100)))
>>> plt.title("title")
>>> plt.show(g)
Step 4
Step 2
Step 1
Step 5
Step 3
1
>>> titanic = sns.load_dataset("titanic")
>>> iris = sns.load_dataset("iris")
Seaborn also offers built-in data sets:
2
3
Further Customizations4
Show or Save Plot
>>> sns.set() (Re)set the seaborn default
>>> sns.set_style("whitegrid") Set the matplotlib parameters
>>> sns.set_style("ticks", Set the matplotlib parameters
{"xtick.major.size":8,
"ytick.major.size":8})
>>> sns.axes_style("whitegrid") Return a dict of params or use with
with to temporarily set the style
Axis Grids
>>> f, ax = plt.subplots(figsize=(5,6)) Create a figure and one subplot
>>> plt.title("A Title") Add plot title
>>> plt.ylabel("Survived") Adjust the label of the y-axis
>>> plt.xlabel("Sex") Adjust the label of the x-axis
>>> plt.ylim(0,100) Adjust the limits of the y-axis
>>> plt.xlim(0,10) Adjust the limits of the x-axis
>>> plt.setp(ax,yticks=[0,5]) Adjust a plot property
>>> plt.tight_layout() Adjust subplot params
>>> plt.show() Show the plot
>>> plt.savefig("foo.png") Save the plot as a figure
>>> plt.savefig("foo.png", Save transparent figure
transparent=True)
>>> sns.regplot(x="sepal_width", Plot data and a linear regression
y="sepal_length", model fit
data=iris,
ax=ax)
>>> g.despine(left=True) Remove left spine
>>> g.set_ylabels("Survived") Set the labels of the y-axis
>>> g.set_xticklabels(rotation=45) Set the tick labels for x
>>> g.set_axis_labels("Survived", Set the axis labels
"Sex")
>>> h.set(xlim=(0,5), Set the limit and ticks of the
ylim=(0,5), x-and y-axis
xticks=[0,2.5,5],
yticks=[0,2.5,5])
Close & Clear
>>> plt.cla() Clear an axis
>>> plt.clf() Clear an entire figure
>>> plt.close() Close a window
5
Also see Lists, NumPy & Pandas
Also see Matplotlib
Also see Matplotlib
Also see Matplotlib
Also see Matplotlib
Context Functions
>>> sns.set_context("talk") Set context to "talk"
>>> sns.set_context("notebook", Set context to "notebook",
font_scale=1.5, Scale font elements and
rc={"lines.linewidth":2.5}) override param mapping
Seaborn styles
>>> sns.set_palette("husl",3) Define the color palette
>>> sns.color_palette("husl") Use with with to temporarily set palette
>>> flatui = ["#9b59b6","#3498db","#95a5a6","#e74c3c","#34495e","#2ecc71"]
>>> sns.set_palette(flatui) Set your own color palette
Color Palette
Plot
Axisgrid Objects
>>> g = sns.FacetGrid(titanic, Subplot grid for plotting conditional
col="survived", relationships
row="sex")
>>> g = g.map(plt.hist,"age")
>>> sns.factorplot(x="pclass", Draw a categorical plot onto a
y="survived", Facetgrid
hue="sex",
data=titanic)
>>> sns.lmplot(x="sepal_width", Plot data and regression model fits
y="sepal_length", across a FacetGrid
hue="species",
data=iris)
Regression PlotsCategorical Plots
Scatterplot
>>> sns.stripplot(x="species", Scatterplot with one
y="petal_length", categorical variable
data=iris)
>>> sns.swarmplot(x="species", Categorical scatterplot with
y="petal_length", non-overlapping points
data=iris)
Bar Chart
>>> sns.barplot(x="sex", Show point estimates and
y="survived", confidence intervals with
hue="class", scatterplot glyphs
data=titanic)
Count Plot
>>> sns.countplot(x="deck", Show count of observations
data=titanic,
palette="Greens_d")
Point Plot
>>> sns.pointplot(x="class", Show point estimates and
y="survived", confidence intervals as
hue="sex", rectangular bars
data=titanic,
palette={"male":"g",
"female":"m"},
markers=["^","o"],
linestyles=["-","--"])
Boxplot
>>> sns.boxplot(x="alive", Boxplot
y="age",
hue="adult_male",
data=titanic)
>>> sns.boxplot(data=iris,orient="h") Boxplot with wide-form data
Violinplot
>>> sns.violinplot(x="age", Violin plot
y="sex",
hue="survived",
data=titanic)
>>> plot = sns.distplot(data.y, Plot univariate distribution
kde=False,
color="b")
Distribution Plots
>>> h = sns.PairGrid(iris) Subplot grid for plotting pairwise
>>> h = h.map(plt.scatter) relationships
>>> sns.pairplot(iris) Plot pairwise bivariate distributions
>>> i = sns.JointGrid(x="x", Grid for bivariate plot with marginal
y="y", univariate plots
data=data)
>>> i = i.plot(sns.regplot,
sns.distplot)
>>> sns.jointplot("sepal_length", Plot bivariate distribution
"sepal_width",
data=iris,
kind='kde')
Matrix Plots
>>> sns.heatmap(uniform_data,vmin=0,vmax=1) Heatmap

More Related Content

What's hot

Python3 cheatsheet
Python3 cheatsheetPython3 cheatsheet
Python3 cheatsheetGil Cohen
 
Cheat sheets for AI
Cheat sheets for AICheat sheets for AI
Cheat sheets for AINcib Lotfi
 
Python Pandas for Data Science cheatsheet
Python Pandas for Data Science cheatsheet Python Pandas for Data Science cheatsheet
Python Pandas for Data Science cheatsheet Dr. Volkan OBAN
 
Python - Numpy/Pandas/Matplot Machine Learning Libraries
Python - Numpy/Pandas/Matplot Machine Learning LibrariesPython - Numpy/Pandas/Matplot Machine Learning Libraries
Python - Numpy/Pandas/Matplot Machine Learning LibrariesAndrew Ferlitsch
 
Recursion(Advanced data structure)
Recursion(Advanced data structure)Recursion(Advanced data structure)
Recursion(Advanced data structure)kurubameena1
 
Data structure using c module 1
Data structure using c module 1Data structure using c module 1
Data structure using c module 1smruti sarangi
 
Python Programming: Lists, Modules, Exceptions
Python Programming: Lists, Modules, ExceptionsPython Programming: Lists, Modules, Exceptions
Python Programming: Lists, Modules, ExceptionsSreedhar Chowdam
 
Introduction to numpy Session 1
Introduction to numpy Session 1Introduction to numpy Session 1
Introduction to numpy Session 1Jatin Miglani
 
Introduction to NumPy
Introduction to NumPyIntroduction to NumPy
Introduction to NumPyHuy Nguyen
 
Data visualization in Python
Data visualization in PythonData visualization in Python
Data visualization in PythonMarc Garcia
 
pandas - Python Data Analysis
pandas - Python Data Analysispandas - Python Data Analysis
pandas - Python Data AnalysisAndrew Henshaw
 
Python-List comprehension
Python-List comprehensionPython-List comprehension
Python-List comprehensionColin Su
 

What's hot (20)

Python3 cheatsheet
Python3 cheatsheetPython3 cheatsheet
Python3 cheatsheet
 
Cheat sheets for AI
Cheat sheets for AICheat sheets for AI
Cheat sheets for AI
 
Python Pandas for Data Science cheatsheet
Python Pandas for Data Science cheatsheet Python Pandas for Data Science cheatsheet
Python Pandas for Data Science cheatsheet
 
2D Array
2D Array2D Array
2D Array
 
Python - Numpy/Pandas/Matplot Machine Learning Libraries
Python - Numpy/Pandas/Matplot Machine Learning LibrariesPython - Numpy/Pandas/Matplot Machine Learning Libraries
Python - Numpy/Pandas/Matplot Machine Learning Libraries
 
NUMPY-2.pptx
NUMPY-2.pptxNUMPY-2.pptx
NUMPY-2.pptx
 
Recursion(Advanced data structure)
Recursion(Advanced data structure)Recursion(Advanced data structure)
Recursion(Advanced data structure)
 
Data structure using c module 1
Data structure using c module 1Data structure using c module 1
Data structure using c module 1
 
MatplotLib.pptx
MatplotLib.pptxMatplotLib.pptx
MatplotLib.pptx
 
Python Programming: Lists, Modules, Exceptions
Python Programming: Lists, Modules, ExceptionsPython Programming: Lists, Modules, Exceptions
Python Programming: Lists, Modules, Exceptions
 
Introduction to numpy Session 1
Introduction to numpy Session 1Introduction to numpy Session 1
Introduction to numpy Session 1
 
C++ string
C++ stringC++ string
C++ string
 
Python Programming
Python Programming Python Programming
Python Programming
 
Introduction to NumPy
Introduction to NumPyIntroduction to NumPy
Introduction to NumPy
 
Data visualization in Python
Data visualization in PythonData visualization in Python
Data visualization in Python
 
Tries data structures
Tries data structuresTries data structures
Tries data structures
 
pandas - Python Data Analysis
pandas - Python Data Analysispandas - Python Data Analysis
pandas - Python Data Analysis
 
Bucket sort
Bucket sortBucket sort
Bucket sort
 
Python-List comprehension
Python-List comprehensionPython-List comprehension
Python-List comprehension
 
Slicing
SlicingSlicing
Slicing
 

Similar to Python seaborn cheat_sheet

The Ring programming language version 1.5 book - Part 8 of 31
The Ring programming language version 1.5 book - Part 8 of 31The Ring programming language version 1.5 book - Part 8 of 31
The Ring programming language version 1.5 book - Part 8 of 31Mahmoud Samir Fayed
 
The Ring programming language version 1.7 book - Part 48 of 196
The Ring programming language version 1.7 book - Part 48 of 196The Ring programming language version 1.7 book - Part 48 of 196
The Ring programming language version 1.7 book - Part 48 of 196Mahmoud Samir Fayed
 
An overview of Python 2.7
An overview of Python 2.7An overview of Python 2.7
An overview of Python 2.7decoupled
 
UNIT III_Python Programming_aditya COllege
UNIT III_Python Programming_aditya COllegeUNIT III_Python Programming_aditya COllege
UNIT III_Python Programming_aditya COllegeRamanamurthy Banda
 
UNIT III_Python Programming_aditya COllege
UNIT III_Python Programming_aditya COllegeUNIT III_Python Programming_aditya COllege
UNIT III_Python Programming_aditya COllegeRamanamurthy Banda
 
python-cheatsheets.pdf
python-cheatsheets.pdfpython-cheatsheets.pdf
python-cheatsheets.pdfKalyan969491
 
python-cheatsheets that will be for coders
python-cheatsheets that will be for coderspython-cheatsheets that will be for coders
python-cheatsheets that will be for coderssarafbisesh
 
The Ring programming language version 1.5.3 book - Part 54 of 184
The Ring programming language version 1.5.3 book - Part 54 of 184The Ring programming language version 1.5.3 book - Part 54 of 184
The Ring programming language version 1.5.3 book - Part 54 of 184Mahmoud Samir Fayed
 
The Ring programming language version 1.5.3 book - Part 44 of 184
The Ring programming language version 1.5.3 book - Part 44 of 184The Ring programming language version 1.5.3 book - Part 44 of 184
The Ring programming language version 1.5.3 book - Part 44 of 184Mahmoud Samir Fayed
 
Refactoring to Macros with Clojure
Refactoring to Macros with ClojureRefactoring to Macros with Clojure
Refactoring to Macros with ClojureDmitry Buzdin
 
Python Cheat Sheet Presentation Learning
Python Cheat Sheet Presentation LearningPython Cheat Sheet Presentation Learning
Python Cheat Sheet Presentation LearningNaseer-ul-Hassan Rehman
 
Python과 node.js기반 데이터 분석 및 가시화
Python과 node.js기반 데이터 분석 및 가시화Python과 node.js기반 데이터 분석 및 가시화
Python과 node.js기반 데이터 분석 및 가시화Tae wook kang
 
The Ring programming language version 1.8 book - Part 50 of 202
The Ring programming language version 1.8 book - Part 50 of 202The Ring programming language version 1.8 book - Part 50 of 202
The Ring programming language version 1.8 book - Part 50 of 202Mahmoud Samir Fayed
 
Effective Numerical Computation in NumPy and SciPy
Effective Numerical Computation in NumPy and SciPyEffective Numerical Computation in NumPy and SciPy
Effective Numerical Computation in NumPy and SciPyKimikazu Kato
 
PPT on Data Science Using Python
PPT on Data Science Using PythonPPT on Data Science Using Python
PPT on Data Science Using PythonNishantKumar1179
 
Scikit learn cheat_sheet_python
Scikit learn cheat_sheet_pythonScikit learn cheat_sheet_python
Scikit learn cheat_sheet_pythonZahid Hasan
 
Scikit-learn Cheatsheet-Python
Scikit-learn Cheatsheet-PythonScikit-learn Cheatsheet-Python
Scikit-learn Cheatsheet-PythonDr. Volkan OBAN
 

Similar to Python seaborn cheat_sheet (20)

The Ring programming language version 1.5 book - Part 8 of 31
The Ring programming language version 1.5 book - Part 8 of 31The Ring programming language version 1.5 book - Part 8 of 31
The Ring programming language version 1.5 book - Part 8 of 31
 
The Ring programming language version 1.7 book - Part 48 of 196
The Ring programming language version 1.7 book - Part 48 of 196The Ring programming language version 1.7 book - Part 48 of 196
The Ring programming language version 1.7 book - Part 48 of 196
 
An overview of Python 2.7
An overview of Python 2.7An overview of Python 2.7
An overview of Python 2.7
 
A tour of Python
A tour of PythonA tour of Python
A tour of Python
 
Slides
SlidesSlides
Slides
 
UNIT III_Python Programming_aditya COllege
UNIT III_Python Programming_aditya COllegeUNIT III_Python Programming_aditya COllege
UNIT III_Python Programming_aditya COllege
 
UNIT III_Python Programming_aditya COllege
UNIT III_Python Programming_aditya COllegeUNIT III_Python Programming_aditya COllege
UNIT III_Python Programming_aditya COllege
 
python-cheatsheets.pdf
python-cheatsheets.pdfpython-cheatsheets.pdf
python-cheatsheets.pdf
 
python-cheatsheets that will be for coders
python-cheatsheets that will be for coderspython-cheatsheets that will be for coders
python-cheatsheets that will be for coders
 
The Ring programming language version 1.5.3 book - Part 54 of 184
The Ring programming language version 1.5.3 book - Part 54 of 184The Ring programming language version 1.5.3 book - Part 54 of 184
The Ring programming language version 1.5.3 book - Part 54 of 184
 
The Ring programming language version 1.5.3 book - Part 44 of 184
The Ring programming language version 1.5.3 book - Part 44 of 184The Ring programming language version 1.5.3 book - Part 44 of 184
The Ring programming language version 1.5.3 book - Part 44 of 184
 
Refactoring to Macros with Clojure
Refactoring to Macros with ClojureRefactoring to Macros with Clojure
Refactoring to Macros with Clojure
 
Python Cheat Sheet Presentation Learning
Python Cheat Sheet Presentation LearningPython Cheat Sheet Presentation Learning
Python Cheat Sheet Presentation Learning
 
Python과 node.js기반 데이터 분석 및 가시화
Python과 node.js기반 데이터 분석 및 가시화Python과 node.js기반 데이터 분석 및 가시화
Python과 node.js기반 데이터 분석 및 가시화
 
The Ring programming language version 1.8 book - Part 50 of 202
The Ring programming language version 1.8 book - Part 50 of 202The Ring programming language version 1.8 book - Part 50 of 202
The Ring programming language version 1.8 book - Part 50 of 202
 
Welcome to python
Welcome to pythonWelcome to python
Welcome to python
 
Effective Numerical Computation in NumPy and SciPy
Effective Numerical Computation in NumPy and SciPyEffective Numerical Computation in NumPy and SciPy
Effective Numerical Computation in NumPy and SciPy
 
PPT on Data Science Using Python
PPT on Data Science Using PythonPPT on Data Science Using Python
PPT on Data Science Using Python
 
Scikit learn cheat_sheet_python
Scikit learn cheat_sheet_pythonScikit learn cheat_sheet_python
Scikit learn cheat_sheet_python
 
Scikit-learn Cheatsheet-Python
Scikit-learn Cheatsheet-PythonScikit-learn Cheatsheet-Python
Scikit-learn Cheatsheet-Python
 

More from Nishant Upadhyay

More from Nishant Upadhyay (14)

Multivariate calculus
Multivariate calculusMultivariate calculus
Multivariate calculus
 
Multivariate calculus
Multivariate calculusMultivariate calculus
Multivariate calculus
 
Matrices1
Matrices1Matrices1
Matrices1
 
Vectors2
Vectors2Vectors2
Vectors2
 
Mathematics for machine learning calculus formulasheet
Mathematics for machine learning calculus formulasheetMathematics for machine learning calculus formulasheet
Mathematics for machine learning calculus formulasheet
 
Pandas pythonfordatascience
Pandas pythonfordatasciencePandas pythonfordatascience
Pandas pythonfordatascience
 
Numpy python cheat_sheet
Numpy python cheat_sheetNumpy python cheat_sheet
Numpy python cheat_sheet
 
Maths4ml linearalgebra-formula
Maths4ml linearalgebra-formulaMaths4ml linearalgebra-formula
Maths4ml linearalgebra-formula
 
Sqlcheetsheet
SqlcheetsheetSqlcheetsheet
Sqlcheetsheet
 
Sql cheat-sheet
Sql cheat-sheetSql cheat-sheet
Sql cheat-sheet
 
My sql installationguide_windows
My sql installationguide_windowsMy sql installationguide_windows
My sql installationguide_windows
 
Company handout
Company handoutCompany handout
Company handout
 
Python bokeh cheat_sheet
Python bokeh cheat_sheet Python bokeh cheat_sheet
Python bokeh cheat_sheet
 
Foliumcheatsheet
FoliumcheatsheetFoliumcheatsheet
Foliumcheatsheet
 

Recently uploaded

Webinar One View, Multiple Systems No-Code Integration of Salesforce and ERPs
Webinar One View, Multiple Systems No-Code Integration of Salesforce and ERPsWebinar One View, Multiple Systems No-Code Integration of Salesforce and ERPs
Webinar One View, Multiple Systems No-Code Integration of Salesforce and ERPsCEPTES Software Inc
 
Tabula.io Cheatsheet: automate your data workflows
Tabula.io Cheatsheet: automate your data workflowsTabula.io Cheatsheet: automate your data workflows
Tabula.io Cheatsheet: automate your data workflowsalex933524
 
How can I successfully sell my pi coins in Philippines?
How can I successfully sell my pi coins in Philippines?How can I successfully sell my pi coins in Philippines?
How can I successfully sell my pi coins in Philippines?DOT TECH
 
一比一原版(QU毕业证)皇后大学毕业证成绩单
一比一原版(QU毕业证)皇后大学毕业证成绩单一比一原版(QU毕业证)皇后大学毕业证成绩单
一比一原版(QU毕业证)皇后大学毕业证成绩单enxupq
 
一比一原版(UVic毕业证)维多利亚大学毕业证成绩单
一比一原版(UVic毕业证)维多利亚大学毕业证成绩单一比一原版(UVic毕业证)维多利亚大学毕业证成绩单
一比一原版(UVic毕业证)维多利亚大学毕业证成绩单ukgaet
 
Criminal IP - Threat Hunting Webinar.pdf
Criminal IP - Threat Hunting Webinar.pdfCriminal IP - Threat Hunting Webinar.pdf
Criminal IP - Threat Hunting Webinar.pdfCriminal IP
 
Innovative Methods in Media and Communication Research by Sebastian Kubitschk...
Innovative Methods in Media and Communication Research by Sebastian Kubitschk...Innovative Methods in Media and Communication Research by Sebastian Kubitschk...
Innovative Methods in Media and Communication Research by Sebastian Kubitschk...correoyaya
 
standardisation of garbhpala offhgfffghh
standardisation of garbhpala offhgfffghhstandardisation of garbhpala offhgfffghh
standardisation of garbhpala offhgfffghhArpitMalhotra16
 
tapal brand analysis PPT slide for comptetive data
tapal brand analysis PPT slide for comptetive datatapal brand analysis PPT slide for comptetive data
tapal brand analysis PPT slide for comptetive datatheahmadsaood
 
一比一原版(UPenn毕业证)宾夕法尼亚大学毕业证成绩单
一比一原版(UPenn毕业证)宾夕法尼亚大学毕业证成绩单一比一原版(UPenn毕业证)宾夕法尼亚大学毕业证成绩单
一比一原版(UPenn毕业证)宾夕法尼亚大学毕业证成绩单ewymefz
 
一比一原版(CU毕业证)卡尔顿大学毕业证成绩单
一比一原版(CU毕业证)卡尔顿大学毕业证成绩单一比一原版(CU毕业证)卡尔顿大学毕业证成绩单
一比一原版(CU毕业证)卡尔顿大学毕业证成绩单yhkoc
 
Predicting Product Ad Campaign Performance: A Data Analysis Project Presentation
Predicting Product Ad Campaign Performance: A Data Analysis Project PresentationPredicting Product Ad Campaign Performance: A Data Analysis Project Presentation
Predicting Product Ad Campaign Performance: A Data Analysis Project PresentationBoston Institute of Analytics
 
Opendatabay - Open Data Marketplace.pptx
Opendatabay - Open Data Marketplace.pptxOpendatabay - Open Data Marketplace.pptx
Opendatabay - Open Data Marketplace.pptxOpendatabay
 
一比一原版(UofM毕业证)明尼苏达大学毕业证成绩单
一比一原版(UofM毕业证)明尼苏达大学毕业证成绩单一比一原版(UofM毕业证)明尼苏达大学毕业证成绩单
一比一原版(UofM毕业证)明尼苏达大学毕业证成绩单ewymefz
 
2024-05-14 - Tableau User Group - TC24 Hot Topics - Tableau Pulse and Einstei...
2024-05-14 - Tableau User Group - TC24 Hot Topics - Tableau Pulse and Einstei...2024-05-14 - Tableau User Group - TC24 Hot Topics - Tableau Pulse and Einstei...
2024-05-14 - Tableau User Group - TC24 Hot Topics - Tableau Pulse and Einstei...elinavihriala
 
Professional Data Engineer Certification Exam Guide  _  Learn  _  Google Clou...
Professional Data Engineer Certification Exam Guide  _  Learn  _  Google Clou...Professional Data Engineer Certification Exam Guide  _  Learn  _  Google Clou...
Professional Data Engineer Certification Exam Guide  _  Learn  _  Google Clou...Domenico Conte
 
Introduction-to-Cybersecurit57hhfcbbcxxx
Introduction-to-Cybersecurit57hhfcbbcxxxIntroduction-to-Cybersecurit57hhfcbbcxxx
Introduction-to-Cybersecurit57hhfcbbcxxxzahraomer517
 
Q1’2024 Update: MYCI’s Leap Year Rebound
Q1’2024 Update: MYCI’s Leap Year ReboundQ1’2024 Update: MYCI’s Leap Year Rebound
Q1’2024 Update: MYCI’s Leap Year ReboundOppotus
 
Jpolillo Amazon PPC - Bid Optimization Sample
Jpolillo Amazon PPC - Bid Optimization SampleJpolillo Amazon PPC - Bid Optimization Sample
Jpolillo Amazon PPC - Bid Optimization SampleJames Polillo
 
一比一原版(CBU毕业证)卡普顿大学毕业证成绩单
一比一原版(CBU毕业证)卡普顿大学毕业证成绩单一比一原版(CBU毕业证)卡普顿大学毕业证成绩单
一比一原版(CBU毕业证)卡普顿大学毕业证成绩单nscud
 

Recently uploaded (20)

Webinar One View, Multiple Systems No-Code Integration of Salesforce and ERPs
Webinar One View, Multiple Systems No-Code Integration of Salesforce and ERPsWebinar One View, Multiple Systems No-Code Integration of Salesforce and ERPs
Webinar One View, Multiple Systems No-Code Integration of Salesforce and ERPs
 
Tabula.io Cheatsheet: automate your data workflows
Tabula.io Cheatsheet: automate your data workflowsTabula.io Cheatsheet: automate your data workflows
Tabula.io Cheatsheet: automate your data workflows
 
How can I successfully sell my pi coins in Philippines?
How can I successfully sell my pi coins in Philippines?How can I successfully sell my pi coins in Philippines?
How can I successfully sell my pi coins in Philippines?
 
一比一原版(QU毕业证)皇后大学毕业证成绩单
一比一原版(QU毕业证)皇后大学毕业证成绩单一比一原版(QU毕业证)皇后大学毕业证成绩单
一比一原版(QU毕业证)皇后大学毕业证成绩单
 
一比一原版(UVic毕业证)维多利亚大学毕业证成绩单
一比一原版(UVic毕业证)维多利亚大学毕业证成绩单一比一原版(UVic毕业证)维多利亚大学毕业证成绩单
一比一原版(UVic毕业证)维多利亚大学毕业证成绩单
 
Criminal IP - Threat Hunting Webinar.pdf
Criminal IP - Threat Hunting Webinar.pdfCriminal IP - Threat Hunting Webinar.pdf
Criminal IP - Threat Hunting Webinar.pdf
 
Innovative Methods in Media and Communication Research by Sebastian Kubitschk...
Innovative Methods in Media and Communication Research by Sebastian Kubitschk...Innovative Methods in Media and Communication Research by Sebastian Kubitschk...
Innovative Methods in Media and Communication Research by Sebastian Kubitschk...
 
standardisation of garbhpala offhgfffghh
standardisation of garbhpala offhgfffghhstandardisation of garbhpala offhgfffghh
standardisation of garbhpala offhgfffghh
 
tapal brand analysis PPT slide for comptetive data
tapal brand analysis PPT slide for comptetive datatapal brand analysis PPT slide for comptetive data
tapal brand analysis PPT slide for comptetive data
 
一比一原版(UPenn毕业证)宾夕法尼亚大学毕业证成绩单
一比一原版(UPenn毕业证)宾夕法尼亚大学毕业证成绩单一比一原版(UPenn毕业证)宾夕法尼亚大学毕业证成绩单
一比一原版(UPenn毕业证)宾夕法尼亚大学毕业证成绩单
 
一比一原版(CU毕业证)卡尔顿大学毕业证成绩单
一比一原版(CU毕业证)卡尔顿大学毕业证成绩单一比一原版(CU毕业证)卡尔顿大学毕业证成绩单
一比一原版(CU毕业证)卡尔顿大学毕业证成绩单
 
Predicting Product Ad Campaign Performance: A Data Analysis Project Presentation
Predicting Product Ad Campaign Performance: A Data Analysis Project PresentationPredicting Product Ad Campaign Performance: A Data Analysis Project Presentation
Predicting Product Ad Campaign Performance: A Data Analysis Project Presentation
 
Opendatabay - Open Data Marketplace.pptx
Opendatabay - Open Data Marketplace.pptxOpendatabay - Open Data Marketplace.pptx
Opendatabay - Open Data Marketplace.pptx
 
一比一原版(UofM毕业证)明尼苏达大学毕业证成绩单
一比一原版(UofM毕业证)明尼苏达大学毕业证成绩单一比一原版(UofM毕业证)明尼苏达大学毕业证成绩单
一比一原版(UofM毕业证)明尼苏达大学毕业证成绩单
 
2024-05-14 - Tableau User Group - TC24 Hot Topics - Tableau Pulse and Einstei...
2024-05-14 - Tableau User Group - TC24 Hot Topics - Tableau Pulse and Einstei...2024-05-14 - Tableau User Group - TC24 Hot Topics - Tableau Pulse and Einstei...
2024-05-14 - Tableau User Group - TC24 Hot Topics - Tableau Pulse and Einstei...
 
Professional Data Engineer Certification Exam Guide  _  Learn  _  Google Clou...
Professional Data Engineer Certification Exam Guide  _  Learn  _  Google Clou...Professional Data Engineer Certification Exam Guide  _  Learn  _  Google Clou...
Professional Data Engineer Certification Exam Guide  _  Learn  _  Google Clou...
 
Introduction-to-Cybersecurit57hhfcbbcxxx
Introduction-to-Cybersecurit57hhfcbbcxxxIntroduction-to-Cybersecurit57hhfcbbcxxx
Introduction-to-Cybersecurit57hhfcbbcxxx
 
Q1’2024 Update: MYCI’s Leap Year Rebound
Q1’2024 Update: MYCI’s Leap Year ReboundQ1’2024 Update: MYCI’s Leap Year Rebound
Q1’2024 Update: MYCI’s Leap Year Rebound
 
Jpolillo Amazon PPC - Bid Optimization Sample
Jpolillo Amazon PPC - Bid Optimization SampleJpolillo Amazon PPC - Bid Optimization Sample
Jpolillo Amazon PPC - Bid Optimization Sample
 
一比一原版(CBU毕业证)卡普顿大学毕业证成绩单
一比一原版(CBU毕业证)卡普顿大学毕业证成绩单一比一原版(CBU毕业证)卡普顿大学毕业证成绩单
一比一原版(CBU毕业证)卡普顿大学毕业证成绩单
 

Python seaborn cheat_sheet

  • 1. PythonForDataScience Cheat Sheet Seaborn Learn Data Science Interactively at www.DataCamp.com Statistical Data Visualization With Seaborn DataCamp Learn Python for Data Science Interactively Figure Aesthetics Data The Python visualization library Seaborn is based on matplotlib and provides a high-level interface for drawing attractive statistical graphics. Make use of the following aliases to import the libraries: The basic steps to creating plots with Seaborn are: 1. Prepare some data 2. Control figure aesthetics 3. Plot with Seaborn 4. Further customize your plot >>> import pandas as pd >>> import numpy as np >>> uniform_data = np.random.rand(10, 12) >>> data = pd.DataFrame({'x':np.arange(1,101), 'y':np.random.normal(0,4,100)}) >>> import matplotlib.pyplot as plt >>> import seaborn as sns Plotting With Seaborn >>> import matplotlib.pyplot as plt >>> import seaborn as sns >>> tips = sns.load_dataset("tips") >>> sns.set_style("whitegrid") >>> g = sns.lmplot(x="tip", y="total_bill", data=tips, aspect=2) >>> g = (g.set_axis_labels("Tip","Total bill(USD)"). set(xlim=(0,10),ylim=(0,100))) >>> plt.title("title") >>> plt.show(g) Step 4 Step 2 Step 1 Step 5 Step 3 1 >>> titanic = sns.load_dataset("titanic") >>> iris = sns.load_dataset("iris") Seaborn also offers built-in data sets: 2 3 Further Customizations4 Show or Save Plot >>> sns.set() (Re)set the seaborn default >>> sns.set_style("whitegrid") Set the matplotlib parameters >>> sns.set_style("ticks", Set the matplotlib parameters {"xtick.major.size":8, "ytick.major.size":8}) >>> sns.axes_style("whitegrid") Return a dict of params or use with with to temporarily set the style Axis Grids >>> f, ax = plt.subplots(figsize=(5,6)) Create a figure and one subplot >>> plt.title("A Title") Add plot title >>> plt.ylabel("Survived") Adjust the label of the y-axis >>> plt.xlabel("Sex") Adjust the label of the x-axis >>> plt.ylim(0,100) Adjust the limits of the y-axis >>> plt.xlim(0,10) Adjust the limits of the x-axis >>> plt.setp(ax,yticks=[0,5]) Adjust a plot property >>> plt.tight_layout() Adjust subplot params >>> plt.show() Show the plot >>> plt.savefig("foo.png") Save the plot as a figure >>> plt.savefig("foo.png", Save transparent figure transparent=True) >>> sns.regplot(x="sepal_width", Plot data and a linear regression y="sepal_length", model fit data=iris, ax=ax) >>> g.despine(left=True) Remove left spine >>> g.set_ylabels("Survived") Set the labels of the y-axis >>> g.set_xticklabels(rotation=45) Set the tick labels for x >>> g.set_axis_labels("Survived", Set the axis labels "Sex") >>> h.set(xlim=(0,5), Set the limit and ticks of the ylim=(0,5), x-and y-axis xticks=[0,2.5,5], yticks=[0,2.5,5]) Close & Clear >>> plt.cla() Clear an axis >>> plt.clf() Clear an entire figure >>> plt.close() Close a window 5 Also see Lists, NumPy & Pandas Also see Matplotlib Also see Matplotlib Also see Matplotlib Also see Matplotlib Context Functions >>> sns.set_context("talk") Set context to "talk" >>> sns.set_context("notebook", Set context to "notebook", font_scale=1.5, Scale font elements and rc={"lines.linewidth":2.5}) override param mapping Seaborn styles >>> sns.set_palette("husl",3) Define the color palette >>> sns.color_palette("husl") Use with with to temporarily set palette >>> flatui = ["#9b59b6","#3498db","#95a5a6","#e74c3c","#34495e","#2ecc71"] >>> sns.set_palette(flatui) Set your own color palette Color Palette Plot Axisgrid Objects >>> g = sns.FacetGrid(titanic, Subplot grid for plotting conditional col="survived", relationships row="sex") >>> g = g.map(plt.hist,"age") >>> sns.factorplot(x="pclass", Draw a categorical plot onto a y="survived", Facetgrid hue="sex", data=titanic) >>> sns.lmplot(x="sepal_width", Plot data and regression model fits y="sepal_length", across a FacetGrid hue="species", data=iris) Regression PlotsCategorical Plots Scatterplot >>> sns.stripplot(x="species", Scatterplot with one y="petal_length", categorical variable data=iris) >>> sns.swarmplot(x="species", Categorical scatterplot with y="petal_length", non-overlapping points data=iris) Bar Chart >>> sns.barplot(x="sex", Show point estimates and y="survived", confidence intervals with hue="class", scatterplot glyphs data=titanic) Count Plot >>> sns.countplot(x="deck", Show count of observations data=titanic, palette="Greens_d") Point Plot >>> sns.pointplot(x="class", Show point estimates and y="survived", confidence intervals as hue="sex", rectangular bars data=titanic, palette={"male":"g", "female":"m"}, markers=["^","o"], linestyles=["-","--"]) Boxplot >>> sns.boxplot(x="alive", Boxplot y="age", hue="adult_male", data=titanic) >>> sns.boxplot(data=iris,orient="h") Boxplot with wide-form data Violinplot >>> sns.violinplot(x="age", Violin plot y="sex", hue="survived", data=titanic) >>> plot = sns.distplot(data.y, Plot univariate distribution kde=False, color="b") Distribution Plots >>> h = sns.PairGrid(iris) Subplot grid for plotting pairwise >>> h = h.map(plt.scatter) relationships >>> sns.pairplot(iris) Plot pairwise bivariate distributions >>> i = sns.JointGrid(x="x", Grid for bivariate plot with marginal y="y", univariate plots data=data) >>> i = i.plot(sns.regplot, sns.distplot) >>> sns.jointplot("sepal_length", Plot bivariate distribution "sepal_width", data=iris, kind='kde') Matrix Plots >>> sns.heatmap(uniform_data,vmin=0,vmax=1) Heatmap