SlideShare a Scribd company logo
1 of 13
Download to read offline
6/17/19, 21)55seaborn_graphing_present
Page 1 of 13http://localhost:8888/nbconvert/html/Desktop/UW/2019%20spring/CSE180/seaborn_graphing_present.ipynb?download=false
In [1]: import pandas as pd
import numpy as np
import seaborn as sns
import matplotlib.pyplot as plt
from IPython.display import display
import matplotlib
%matplotlib inline
In [2]: iris = sns.load_dataset('iris')
tips = sns.load_dataset('tips')
display(iris.head())
print(iris.shape)
display(tips.head())
print(tips.shape)
sepal_length sepal_width petal_length petal_width species
0 5.1 3.5 1.4 0.2 setosa
1 4.9 3.0 1.4 0.2 setosa
2 4.7 3.2 1.3 0.2 setosa
3 4.6 3.1 1.5 0.2 setosa
4 5.0 3.6 1.4 0.2 setosa
(150, 5)
total_bill tip sex smoker day time size
0 16.99 1.01 Female No Sun Dinner 2
1 10.34 1.66 Male No Sun Dinner 3
2 21.01 3.50 Male No Sun Dinner 3
3 23.68 3.31 Male No Sun Dinner 2
4 24.59 3.61 Female No Sun Dinner 4
(244, 7)
6/17/19, 21)55seaborn_graphing_present
Page 2 of 13http://localhost:8888/nbconvert/html/Desktop/UW/2019%20spring/CSE180/seaborn_graphing_present.ipynb?download=false
In [3]: # Boxplot
# sns.set(style="whitegrid")
# with matplotlib
grouped = {g:tips.loc[i,'total_bill'] for g , i in tips.groupby('day')
.groups.items()}
plt.boxplot(grouped.values(), labels=grouped.keys() )
# with pandas
ax = tips.boxplot(by='day', column='total_bill')
plt.show()
ax = sns.boxplot(x='day', y='total_bill', data=tips)
ax.set_title('Boxplot with Seaborn')
Out[3]: Text(0.5, 1.0, 'Boxplot with Seaborn')
6/17/19, 21)55seaborn_graphing_present
Page 3 of 13http://localhost:8888/nbconvert/html/Desktop/UW/2019%20spring/CSE180/seaborn_graphing_present.ipynb?download=false
In [4]: # Stripplot
ax = sns.stripplot(x='day', y='total_bill', data=tips)
6/17/19, 21)55seaborn_graphing_present
Page 4 of 13http://localhost:8888/nbconvert/html/Desktop/UW/2019%20spring/CSE180/seaborn_graphing_present.ipynb?download=false
In [5]: # Stripplot: Let's add a hue and split
ax = sns.stripplot(x='day', y='total_bill', hue='smoker', dodge=True,
data=tips)
In [6]: # Violinplot
ax = sns.violinplot(x="day", y="total_bill", data=tips)
/Users/apple/anaconda3/lib/python3.7/site-packages/scipy/stats/stats
.py:1713: FutureWarning: Using a non-tuple sequence for multidimensi
onal indexing is deprecated; use `arr[tuple(seq)]` instead of `arr[s
eq]`. In the future this will be interpreted as an array index, `arr
[np.array(seq)]`, which will result either in an error or a differen
t result.
return np.add.reduce(sorted[indexer] * weights, axis=axis) / sumva
l
6/17/19, 21)55seaborn_graphing_present
Page 5 of 13http://localhost:8888/nbconvert/html/Desktop/UW/2019%20spring/CSE180/seaborn_graphing_present.ipynb?download=false
In [7]: # Violinplot
ax = sns.violinplot(x="day", y="total_bill", data=tips, hue="smoker")
In [8]: # Violinplot
ax = sns.violinplot(x="day", y="total_bill", data=tips, hue="smoker",
split=True, palette="bright")
6/17/19, 21)55seaborn_graphing_present
Page 6 of 13http://localhost:8888/nbconvert/html/Desktop/UW/2019%20spring/CSE180/seaborn_graphing_present.ipynb?download=false
In [9]: # Violinplot
fig , ax = plt.subplots(figsize=(20,10))
ax = sns.violinplot(x="day", y="total_bill", data=tips, hue="smoker",
split=True, palette="bright",
inner="stick", bw=0.2, ax=ax
)
In [10]: ax = sns.swarmplot(x="day", y="total_bill", hue="smoker", data=tips, p
alette="Set2")
6/17/19, 21)55seaborn_graphing_present
Page 7 of 13http://localhost:8888/nbconvert/html/Desktop/UW/2019%20spring/CSE180/seaborn_graphing_present.ipynb?download=false
A note on color palettes
Seaborn uses Color Brewer sets. This is a cool tool for finding a good (color blind/grayscale friendly).
http://colorbrewer2.org (http://colorbrewer2.org)
In [11]: # Combine a Violinplot and Swarmplot
fig , ax = plt.subplots(figsize=(15,10))
ax = sns.violinplot(x="day", y="total_bill", data=tips, inner=None)
ax = sns.swarmplot(x="day", y="total_bill", data=tips,
color="white", edgecolor="gray", ax=ax)
Distribution Plots
jointplot - two variables
pairplot - grid comparing two-way relationships
6/17/19, 21)55seaborn_graphing_present
Page 8 of 13http://localhost:8888/nbconvert/html/Desktop/UW/2019%20spring/CSE180/seaborn_graphing_present.ipynb?download=false
In [12]: g = sns.jointplot(x="total_bill", y="tip", data=tips)
6/17/19, 21)55seaborn_graphing_present
Page 9 of 13http://localhost:8888/nbconvert/html/Desktop/UW/2019%20spring/CSE180/seaborn_graphing_present.ipynb?download=false
In [13]: g = sns.jointplot("total_bill", "tip", data=tips, kind="reg")
6/17/19, 21)55seaborn_graphing_present
Page 10 of 13http://localhost:8888/nbconvert/html/Desktop/UW/2019%20spring/CSE180/seaborn_graphing_present.ipynb?download=false
In [14]: # Distplot - makes histograms
grouped = {g:iris.loc[i,'petal_length'] for g , i in iris.groupby('spe
cies').groups.items()}
for g , v in grouped.items():
sns.distplot(v, label=g)
plt.legend()
Out[14]: <matplotlib.legend.Legend at 0x1a220d9320>
6/17/19, 21)55seaborn_graphing_present
Page 11 of 13http://localhost:8888/nbconvert/html/Desktop/UW/2019%20spring/CSE180/seaborn_graphing_present.ipynb?download=false
In [15]: # pairplot - look at all pairwise relationships
g = sns.pairplot(iris)
6/17/19, 21)55seaborn_graphing_present
Page 12 of 13http://localhost:8888/nbconvert/html/Desktop/UW/2019%20spring/CSE180/seaborn_graphing_present.ipynb?download=false
In [16]: # pairplot - look at all pairwise relationships
g = sns.pairplot(iris, hue='species', palette='husl')
6/17/19, 21)55seaborn_graphing_present
Page 13 of 13http://localhost:8888/nbconvert/html/Desktop/UW/2019%20spring/CSE180/seaborn_graphing_present.ipynb?download=false
In [17]: # lmplot - plots regplots across multiple variables
g = sns.lmplot(x='sepal_length', y='sepal_width', hue='species', data=
iris, palette='Dark2')
In [ ]:

More Related Content

Similar to Seaborn graphing present

Getting more out of Matplotlib with GR
Getting more out of Matplotlib with GRGetting more out of Matplotlib with GR
Getting more out of Matplotlib with GRJosef Heinen
 
M11 bagging loo cv
M11 bagging loo cvM11 bagging loo cv
M11 bagging loo cvRaman Kannan
 
DSD-INT 2018 Work with iMOD MODFLOW models in Python - Visser Bootsma
DSD-INT 2018 Work with iMOD MODFLOW models in Python - Visser BootsmaDSD-INT 2018 Work with iMOD MODFLOW models in Python - Visser Bootsma
DSD-INT 2018 Work with iMOD MODFLOW models in Python - Visser BootsmaDeltares
 
«iPython & Jupyter: 4 fun & profit», Лев Тонких, Rambler&Co
«iPython & Jupyter: 4 fun & profit», Лев Тонких, Rambler&Co«iPython & Jupyter: 4 fun & profit», Лев Тонких, Rambler&Co
«iPython & Jupyter: 4 fun & profit», Лев Тонких, Rambler&CoMail.ru Group
 
Python for Scientific Computing -- Ricardo Cruz
Python for Scientific Computing -- Ricardo CruzPython for Scientific Computing -- Ricardo Cruz
Python for Scientific Computing -- Ricardo Cruzrpmcruz
 
Python Developer's Daily Routine
Python Developer's Daily RoutinePython Developer's Daily Routine
Python Developer's Daily RoutineMaxim Avanov
 
All I know about rsc.io/c2go
All I know about rsc.io/c2goAll I know about rsc.io/c2go
All I know about rsc.io/c2goMoriyoshi Koizumi
 
Pyconmini Hiroshima 2018
Pyconmini Hiroshima 2018Pyconmini Hiroshima 2018
Pyconmini Hiroshima 2018ksnt
 
Life of PySpark - A tale of two environments
Life of PySpark - A tale of two environmentsLife of PySpark - A tale of two environments
Life of PySpark - A tale of two environmentsShankar M S
 
Data Structure in C (Lab Programs)
Data Structure in C (Lab Programs)Data Structure in C (Lab Programs)
Data Structure in C (Lab Programs)Saket Pathak
 
Dataiku - Paris JUG 2013 - Hadoop is a batch
Dataiku - Paris JUG 2013 - Hadoop is a batch Dataiku - Paris JUG 2013 - Hadoop is a batch
Dataiku - Paris JUG 2013 - Hadoop is a batch Dataiku
 
Green Marl 最新お役立ちTIPS
Green Marl 最新お役立ちTIPSGreen Marl 最新お役立ちTIPS
Green Marl 最新お役立ちTIPSTamakoshi Hironori
 
A CTF Hackers Toolbox
A CTF Hackers ToolboxA CTF Hackers Toolbox
A CTF Hackers ToolboxStefan
 
Deploying a Pylons app to Google App Engine
Deploying a Pylons app to Google App EngineDeploying a Pylons app to Google App Engine
Deploying a Pylons app to Google App EngineJazkarta, Inc.
 
Software Vulnerabilities in C and C++ (CppCon 2018)
Software Vulnerabilities in C and C++ (CppCon 2018)Software Vulnerabilities in C and C++ (CppCon 2018)
Software Vulnerabilities in C and C++ (CppCon 2018)Patricia Aas
 
Db2 For I Parallel Data Load
Db2 For I Parallel Data LoadDb2 For I Parallel Data Load
Db2 For I Parallel Data LoadThomas Wolfe
 
AI Presentation - Aug-2018
AI Presentation - Aug-2018AI Presentation - Aug-2018
AI Presentation - Aug-2018Wing Yuen Loon
 
Efficient equity portfolios using mean variance optimisation in R
Efficient equity portfolios using mean variance optimisation in REfficient equity portfolios using mean variance optimisation in R
Efficient equity portfolios using mean variance optimisation in RGregg Barrett
 

Similar to Seaborn graphing present (20)

Getting more out of Matplotlib with GR
Getting more out of Matplotlib with GRGetting more out of Matplotlib with GR
Getting more out of Matplotlib with GR
 
M11 bagging loo cv
M11 bagging loo cvM11 bagging loo cv
M11 bagging loo cv
 
DSD-INT 2018 Work with iMOD MODFLOW models in Python - Visser Bootsma
DSD-INT 2018 Work with iMOD MODFLOW models in Python - Visser BootsmaDSD-INT 2018 Work with iMOD MODFLOW models in Python - Visser Bootsma
DSD-INT 2018 Work with iMOD MODFLOW models in Python - Visser Bootsma
 
«iPython & Jupyter: 4 fun & profit», Лев Тонких, Rambler&Co
«iPython & Jupyter: 4 fun & profit», Лев Тонких, Rambler&Co«iPython & Jupyter: 4 fun & profit», Лев Тонких, Rambler&Co
«iPython & Jupyter: 4 fun & profit», Лев Тонких, Rambler&Co
 
Python for Scientific Computing -- Ricardo Cruz
Python for Scientific Computing -- Ricardo CruzPython for Scientific Computing -- Ricardo Cruz
Python for Scientific Computing -- Ricardo Cruz
 
Python Developer's Daily Routine
Python Developer's Daily RoutinePython Developer's Daily Routine
Python Developer's Daily Routine
 
All I know about rsc.io/c2go
All I know about rsc.io/c2goAll I know about rsc.io/c2go
All I know about rsc.io/c2go
 
Pyconmini Hiroshima 2018
Pyconmini Hiroshima 2018Pyconmini Hiroshima 2018
Pyconmini Hiroshima 2018
 
Life of PySpark - A tale of two environments
Life of PySpark - A tale of two environmentsLife of PySpark - A tale of two environments
Life of PySpark - A tale of two environments
 
Data Structure in C (Lab Programs)
Data Structure in C (Lab Programs)Data Structure in C (Lab Programs)
Data Structure in C (Lab Programs)
 
Matplotlib
MatplotlibMatplotlib
Matplotlib
 
Dataiku - Paris JUG 2013 - Hadoop is a batch
Dataiku - Paris JUG 2013 - Hadoop is a batch Dataiku - Paris JUG 2013 - Hadoop is a batch
Dataiku - Paris JUG 2013 - Hadoop is a batch
 
Green Marl 最新お役立ちTIPS
Green Marl 最新お役立ちTIPSGreen Marl 最新お役立ちTIPS
Green Marl 最新お役立ちTIPS
 
A CTF Hackers Toolbox
A CTF Hackers ToolboxA CTF Hackers Toolbox
A CTF Hackers Toolbox
 
Deploying a Pylons app to Google App Engine
Deploying a Pylons app to Google App EngineDeploying a Pylons app to Google App Engine
Deploying a Pylons app to Google App Engine
 
JQuery Flot
JQuery FlotJQuery Flot
JQuery Flot
 
Software Vulnerabilities in C and C++ (CppCon 2018)
Software Vulnerabilities in C and C++ (CppCon 2018)Software Vulnerabilities in C and C++ (CppCon 2018)
Software Vulnerabilities in C and C++ (CppCon 2018)
 
Db2 For I Parallel Data Load
Db2 For I Parallel Data LoadDb2 For I Parallel Data Load
Db2 For I Parallel Data Load
 
AI Presentation - Aug-2018
AI Presentation - Aug-2018AI Presentation - Aug-2018
AI Presentation - Aug-2018
 
Efficient equity portfolios using mean variance optimisation in R
Efficient equity portfolios using mean variance optimisation in REfficient equity portfolios using mean variance optimisation in R
Efficient equity portfolios using mean variance optimisation in R
 

More from Yilin Zeng

Competitive Analysis
Competitive AnalysisCompetitive Analysis
Competitive AnalysisYilin Zeng
 
Contextual Inquiry
Contextual InquiryContextual Inquiry
Contextual InquiryYilin Zeng
 
Group Deliverable: Interviews & Personas
Group Deliverable: Interviews & PersonasGroup Deliverable: Interviews & Personas
Group Deliverable: Interviews & PersonasYilin Zeng
 
My User Research Deliverable
My User Research DeliverableMy User Research Deliverable
My User Research DeliverableYilin Zeng
 
project proposal
project proposalproject proposal
project proposalYilin Zeng
 
Mitsubachi Arduino code
Mitsubachi Arduino codeMitsubachi Arduino code
Mitsubachi Arduino codeYilin Zeng
 
Project: Mitsubachi
Project: MitsubachiProject: Mitsubachi
Project: MitsubachiYilin Zeng
 
Netflix Analysis
Netflix Analysis Netflix Analysis
Netflix Analysis Yilin Zeng
 
Ethnographic breaching experiment
Ethnographic breaching experiment Ethnographic breaching experiment
Ethnographic breaching experiment Yilin Zeng
 
Inclusive design playbook
Inclusive design playbookInclusive design playbook
Inclusive design playbookYilin Zeng
 

More from Yilin Zeng (10)

Competitive Analysis
Competitive AnalysisCompetitive Analysis
Competitive Analysis
 
Contextual Inquiry
Contextual InquiryContextual Inquiry
Contextual Inquiry
 
Group Deliverable: Interviews & Personas
Group Deliverable: Interviews & PersonasGroup Deliverable: Interviews & Personas
Group Deliverable: Interviews & Personas
 
My User Research Deliverable
My User Research DeliverableMy User Research Deliverable
My User Research Deliverable
 
project proposal
project proposalproject proposal
project proposal
 
Mitsubachi Arduino code
Mitsubachi Arduino codeMitsubachi Arduino code
Mitsubachi Arduino code
 
Project: Mitsubachi
Project: MitsubachiProject: Mitsubachi
Project: Mitsubachi
 
Netflix Analysis
Netflix Analysis Netflix Analysis
Netflix Analysis
 
Ethnographic breaching experiment
Ethnographic breaching experiment Ethnographic breaching experiment
Ethnographic breaching experiment
 
Inclusive design playbook
Inclusive design playbookInclusive design playbook
Inclusive design playbook
 

Recently uploaded

PKS-TGC-1084-630 - Stage 1 Proposal.pptx
PKS-TGC-1084-630 - Stage 1 Proposal.pptxPKS-TGC-1084-630 - Stage 1 Proposal.pptx
PKS-TGC-1084-630 - Stage 1 Proposal.pptxPramod Kumar Srivastava
 
Consent & Privacy Signals on Google *Pixels* - MeasureCamp Amsterdam 2024
Consent & Privacy Signals on Google *Pixels* - MeasureCamp Amsterdam 2024Consent & Privacy Signals on Google *Pixels* - MeasureCamp Amsterdam 2024
Consent & Privacy Signals on Google *Pixels* - MeasureCamp Amsterdam 2024thyngster
 
Kantar AI Summit- Under Embargo till Wednesday, 24th April 2024, 4 PM, IST.pdf
Kantar AI Summit- Under Embargo till Wednesday, 24th April 2024, 4 PM, IST.pdfKantar AI Summit- Under Embargo till Wednesday, 24th April 2024, 4 PM, IST.pdf
Kantar AI Summit- Under Embargo till Wednesday, 24th April 2024, 4 PM, IST.pdfSocial Samosa
 
专业一比一美国俄亥俄大学毕业证成绩单pdf电子版制作修改
专业一比一美国俄亥俄大学毕业证成绩单pdf电子版制作修改专业一比一美国俄亥俄大学毕业证成绩单pdf电子版制作修改
专业一比一美国俄亥俄大学毕业证成绩单pdf电子版制作修改yuu sss
 
办理(Vancouver毕业证书)加拿大温哥华岛大学毕业证成绩单原版一比一
办理(Vancouver毕业证书)加拿大温哥华岛大学毕业证成绩单原版一比一办理(Vancouver毕业证书)加拿大温哥华岛大学毕业证成绩单原版一比一
办理(Vancouver毕业证书)加拿大温哥华岛大学毕业证成绩单原版一比一F La
 
9654467111 Call Girls In Munirka Hotel And Home Service
9654467111 Call Girls In Munirka Hotel And Home Service9654467111 Call Girls In Munirka Hotel And Home Service
9654467111 Call Girls In Munirka Hotel And Home ServiceSapana Sha
 
Dubai Call Girls Wifey O52&786472 Call Girls Dubai
Dubai Call Girls Wifey O52&786472 Call Girls DubaiDubai Call Girls Wifey O52&786472 Call Girls Dubai
Dubai Call Girls Wifey O52&786472 Call Girls Dubaihf8803863
 
Amazon TQM (2) Amazon TQM (2)Amazon TQM (2).pptx
Amazon TQM (2) Amazon TQM (2)Amazon TQM (2).pptxAmazon TQM (2) Amazon TQM (2)Amazon TQM (2).pptx
Amazon TQM (2) Amazon TQM (2)Amazon TQM (2).pptxAbdelrhman abooda
 
办理学位证中佛罗里达大学毕业证,UCF成绩单原版一比一
办理学位证中佛罗里达大学毕业证,UCF成绩单原版一比一办理学位证中佛罗里达大学毕业证,UCF成绩单原版一比一
办理学位证中佛罗里达大学毕业证,UCF成绩单原版一比一F sss
 
Call Girls in Defence Colony Delhi 💯Call Us 🔝8264348440🔝
Call Girls in Defence Colony Delhi 💯Call Us 🔝8264348440🔝Call Girls in Defence Colony Delhi 💯Call Us 🔝8264348440🔝
Call Girls in Defence Colony Delhi 💯Call Us 🔝8264348440🔝soniya singh
 
EMERCE - 2024 - AMSTERDAM - CROSS-PLATFORM TRACKING WITH GOOGLE ANALYTICS.pptx
EMERCE - 2024 - AMSTERDAM - CROSS-PLATFORM  TRACKING WITH GOOGLE ANALYTICS.pptxEMERCE - 2024 - AMSTERDAM - CROSS-PLATFORM  TRACKING WITH GOOGLE ANALYTICS.pptx
EMERCE - 2024 - AMSTERDAM - CROSS-PLATFORM TRACKING WITH GOOGLE ANALYTICS.pptxthyngster
 
Building on a FAIRly Strong Foundation to Connect Academic Research to Transl...
Building on a FAIRly Strong Foundation to Connect Academic Research to Transl...Building on a FAIRly Strong Foundation to Connect Academic Research to Transl...
Building on a FAIRly Strong Foundation to Connect Academic Research to Transl...Jack DiGiovanna
 
vip Sarai Rohilla Call Girls 9999965857 Call or WhatsApp Now Book
vip Sarai Rohilla Call Girls 9999965857 Call or WhatsApp Now Bookvip Sarai Rohilla Call Girls 9999965857 Call or WhatsApp Now Book
vip Sarai Rohilla Call Girls 9999965857 Call or WhatsApp Now Bookmanojkuma9823
 
科罗拉多大学波尔得分校毕业证学位证成绩单-可办理
科罗拉多大学波尔得分校毕业证学位证成绩单-可办理科罗拉多大学波尔得分校毕业证学位证成绩单-可办理
科罗拉多大学波尔得分校毕业证学位证成绩单-可办理e4aez8ss
 
Industrialised data - the key to AI success.pdf
Industrialised data - the key to AI success.pdfIndustrialised data - the key to AI success.pdf
Industrialised data - the key to AI success.pdfLars Albertsson
 
Saket, (-DELHI )+91-9654467111-(=)CHEAP Call Girls in Escorts Service Saket C...
Saket, (-DELHI )+91-9654467111-(=)CHEAP Call Girls in Escorts Service Saket C...Saket, (-DELHI )+91-9654467111-(=)CHEAP Call Girls in Escorts Service Saket C...
Saket, (-DELHI )+91-9654467111-(=)CHEAP Call Girls in Escorts Service Saket C...Sapana Sha
 
dokumen.tips_chapter-4-transient-heat-conduction-mehmet-kanoglu.ppt
dokumen.tips_chapter-4-transient-heat-conduction-mehmet-kanoglu.pptdokumen.tips_chapter-4-transient-heat-conduction-mehmet-kanoglu.ppt
dokumen.tips_chapter-4-transient-heat-conduction-mehmet-kanoglu.pptSonatrach
 
꧁❤ Greater Noida Call Girls Delhi ❤꧂ 9711199171 ☎️ Hard And Sexy Vip Call
꧁❤ Greater Noida Call Girls Delhi ❤꧂ 9711199171 ☎️ Hard And Sexy Vip Call꧁❤ Greater Noida Call Girls Delhi ❤꧂ 9711199171 ☎️ Hard And Sexy Vip Call
꧁❤ Greater Noida Call Girls Delhi ❤꧂ 9711199171 ☎️ Hard And Sexy Vip Callshivangimorya083
 
Call Us ➥97111√47426🤳Call Girls in Aerocity (Delhi NCR)
Call Us ➥97111√47426🤳Call Girls in Aerocity (Delhi NCR)Call Us ➥97111√47426🤳Call Girls in Aerocity (Delhi NCR)
Call Us ➥97111√47426🤳Call Girls in Aerocity (Delhi NCR)jennyeacort
 

Recently uploaded (20)

PKS-TGC-1084-630 - Stage 1 Proposal.pptx
PKS-TGC-1084-630 - Stage 1 Proposal.pptxPKS-TGC-1084-630 - Stage 1 Proposal.pptx
PKS-TGC-1084-630 - Stage 1 Proposal.pptx
 
Consent & Privacy Signals on Google *Pixels* - MeasureCamp Amsterdam 2024
Consent & Privacy Signals on Google *Pixels* - MeasureCamp Amsterdam 2024Consent & Privacy Signals on Google *Pixels* - MeasureCamp Amsterdam 2024
Consent & Privacy Signals on Google *Pixels* - MeasureCamp Amsterdam 2024
 
Kantar AI Summit- Under Embargo till Wednesday, 24th April 2024, 4 PM, IST.pdf
Kantar AI Summit- Under Embargo till Wednesday, 24th April 2024, 4 PM, IST.pdfKantar AI Summit- Under Embargo till Wednesday, 24th April 2024, 4 PM, IST.pdf
Kantar AI Summit- Under Embargo till Wednesday, 24th April 2024, 4 PM, IST.pdf
 
专业一比一美国俄亥俄大学毕业证成绩单pdf电子版制作修改
专业一比一美国俄亥俄大学毕业证成绩单pdf电子版制作修改专业一比一美国俄亥俄大学毕业证成绩单pdf电子版制作修改
专业一比一美国俄亥俄大学毕业证成绩单pdf电子版制作修改
 
办理(Vancouver毕业证书)加拿大温哥华岛大学毕业证成绩单原版一比一
办理(Vancouver毕业证书)加拿大温哥华岛大学毕业证成绩单原版一比一办理(Vancouver毕业证书)加拿大温哥华岛大学毕业证成绩单原版一比一
办理(Vancouver毕业证书)加拿大温哥华岛大学毕业证成绩单原版一比一
 
9654467111 Call Girls In Munirka Hotel And Home Service
9654467111 Call Girls In Munirka Hotel And Home Service9654467111 Call Girls In Munirka Hotel And Home Service
9654467111 Call Girls In Munirka Hotel And Home Service
 
Dubai Call Girls Wifey O52&786472 Call Girls Dubai
Dubai Call Girls Wifey O52&786472 Call Girls DubaiDubai Call Girls Wifey O52&786472 Call Girls Dubai
Dubai Call Girls Wifey O52&786472 Call Girls Dubai
 
Amazon TQM (2) Amazon TQM (2)Amazon TQM (2).pptx
Amazon TQM (2) Amazon TQM (2)Amazon TQM (2).pptxAmazon TQM (2) Amazon TQM (2)Amazon TQM (2).pptx
Amazon TQM (2) Amazon TQM (2)Amazon TQM (2).pptx
 
办理学位证中佛罗里达大学毕业证,UCF成绩单原版一比一
办理学位证中佛罗里达大学毕业证,UCF成绩单原版一比一办理学位证中佛罗里达大学毕业证,UCF成绩单原版一比一
办理学位证中佛罗里达大学毕业证,UCF成绩单原版一比一
 
Call Girls in Defence Colony Delhi 💯Call Us 🔝8264348440🔝
Call Girls in Defence Colony Delhi 💯Call Us 🔝8264348440🔝Call Girls in Defence Colony Delhi 💯Call Us 🔝8264348440🔝
Call Girls in Defence Colony Delhi 💯Call Us 🔝8264348440🔝
 
EMERCE - 2024 - AMSTERDAM - CROSS-PLATFORM TRACKING WITH GOOGLE ANALYTICS.pptx
EMERCE - 2024 - AMSTERDAM - CROSS-PLATFORM  TRACKING WITH GOOGLE ANALYTICS.pptxEMERCE - 2024 - AMSTERDAM - CROSS-PLATFORM  TRACKING WITH GOOGLE ANALYTICS.pptx
EMERCE - 2024 - AMSTERDAM - CROSS-PLATFORM TRACKING WITH GOOGLE ANALYTICS.pptx
 
Building on a FAIRly Strong Foundation to Connect Academic Research to Transl...
Building on a FAIRly Strong Foundation to Connect Academic Research to Transl...Building on a FAIRly Strong Foundation to Connect Academic Research to Transl...
Building on a FAIRly Strong Foundation to Connect Academic Research to Transl...
 
vip Sarai Rohilla Call Girls 9999965857 Call or WhatsApp Now Book
vip Sarai Rohilla Call Girls 9999965857 Call or WhatsApp Now Bookvip Sarai Rohilla Call Girls 9999965857 Call or WhatsApp Now Book
vip Sarai Rohilla Call Girls 9999965857 Call or WhatsApp Now Book
 
科罗拉多大学波尔得分校毕业证学位证成绩单-可办理
科罗拉多大学波尔得分校毕业证学位证成绩单-可办理科罗拉多大学波尔得分校毕业证学位证成绩单-可办理
科罗拉多大学波尔得分校毕业证学位证成绩单-可办理
 
Industrialised data - the key to AI success.pdf
Industrialised data - the key to AI success.pdfIndustrialised data - the key to AI success.pdf
Industrialised data - the key to AI success.pdf
 
Saket, (-DELHI )+91-9654467111-(=)CHEAP Call Girls in Escorts Service Saket C...
Saket, (-DELHI )+91-9654467111-(=)CHEAP Call Girls in Escorts Service Saket C...Saket, (-DELHI )+91-9654467111-(=)CHEAP Call Girls in Escorts Service Saket C...
Saket, (-DELHI )+91-9654467111-(=)CHEAP Call Girls in Escorts Service Saket C...
 
dokumen.tips_chapter-4-transient-heat-conduction-mehmet-kanoglu.ppt
dokumen.tips_chapter-4-transient-heat-conduction-mehmet-kanoglu.pptdokumen.tips_chapter-4-transient-heat-conduction-mehmet-kanoglu.ppt
dokumen.tips_chapter-4-transient-heat-conduction-mehmet-kanoglu.ppt
 
꧁❤ Greater Noida Call Girls Delhi ❤꧂ 9711199171 ☎️ Hard And Sexy Vip Call
꧁❤ Greater Noida Call Girls Delhi ❤꧂ 9711199171 ☎️ Hard And Sexy Vip Call꧁❤ Greater Noida Call Girls Delhi ❤꧂ 9711199171 ☎️ Hard And Sexy Vip Call
꧁❤ Greater Noida Call Girls Delhi ❤꧂ 9711199171 ☎️ Hard And Sexy Vip Call
 
Call Us ➥97111√47426🤳Call Girls in Aerocity (Delhi NCR)
Call Us ➥97111√47426🤳Call Girls in Aerocity (Delhi NCR)Call Us ➥97111√47426🤳Call Girls in Aerocity (Delhi NCR)
Call Us ➥97111√47426🤳Call Girls in Aerocity (Delhi NCR)
 
Deep Generative Learning for All - The Gen AI Hype (Spring 2024)
Deep Generative Learning for All - The Gen AI Hype (Spring 2024)Deep Generative Learning for All - The Gen AI Hype (Spring 2024)
Deep Generative Learning for All - The Gen AI Hype (Spring 2024)
 

Seaborn graphing present

  • 1. 6/17/19, 21)55seaborn_graphing_present Page 1 of 13http://localhost:8888/nbconvert/html/Desktop/UW/2019%20spring/CSE180/seaborn_graphing_present.ipynb?download=false In [1]: import pandas as pd import numpy as np import seaborn as sns import matplotlib.pyplot as plt from IPython.display import display import matplotlib %matplotlib inline In [2]: iris = sns.load_dataset('iris') tips = sns.load_dataset('tips') display(iris.head()) print(iris.shape) display(tips.head()) print(tips.shape) sepal_length sepal_width petal_length petal_width species 0 5.1 3.5 1.4 0.2 setosa 1 4.9 3.0 1.4 0.2 setosa 2 4.7 3.2 1.3 0.2 setosa 3 4.6 3.1 1.5 0.2 setosa 4 5.0 3.6 1.4 0.2 setosa (150, 5) total_bill tip sex smoker day time size 0 16.99 1.01 Female No Sun Dinner 2 1 10.34 1.66 Male No Sun Dinner 3 2 21.01 3.50 Male No Sun Dinner 3 3 23.68 3.31 Male No Sun Dinner 2 4 24.59 3.61 Female No Sun Dinner 4 (244, 7)
  • 2. 6/17/19, 21)55seaborn_graphing_present Page 2 of 13http://localhost:8888/nbconvert/html/Desktop/UW/2019%20spring/CSE180/seaborn_graphing_present.ipynb?download=false In [3]: # Boxplot # sns.set(style="whitegrid") # with matplotlib grouped = {g:tips.loc[i,'total_bill'] for g , i in tips.groupby('day') .groups.items()} plt.boxplot(grouped.values(), labels=grouped.keys() ) # with pandas ax = tips.boxplot(by='day', column='total_bill') plt.show() ax = sns.boxplot(x='day', y='total_bill', data=tips) ax.set_title('Boxplot with Seaborn') Out[3]: Text(0.5, 1.0, 'Boxplot with Seaborn')
  • 3. 6/17/19, 21)55seaborn_graphing_present Page 3 of 13http://localhost:8888/nbconvert/html/Desktop/UW/2019%20spring/CSE180/seaborn_graphing_present.ipynb?download=false In [4]: # Stripplot ax = sns.stripplot(x='day', y='total_bill', data=tips)
  • 4. 6/17/19, 21)55seaborn_graphing_present Page 4 of 13http://localhost:8888/nbconvert/html/Desktop/UW/2019%20spring/CSE180/seaborn_graphing_present.ipynb?download=false In [5]: # Stripplot: Let's add a hue and split ax = sns.stripplot(x='day', y='total_bill', hue='smoker', dodge=True, data=tips) In [6]: # Violinplot ax = sns.violinplot(x="day", y="total_bill", data=tips) /Users/apple/anaconda3/lib/python3.7/site-packages/scipy/stats/stats .py:1713: FutureWarning: Using a non-tuple sequence for multidimensi onal indexing is deprecated; use `arr[tuple(seq)]` instead of `arr[s eq]`. In the future this will be interpreted as an array index, `arr [np.array(seq)]`, which will result either in an error or a differen t result. return np.add.reduce(sorted[indexer] * weights, axis=axis) / sumva l
  • 5. 6/17/19, 21)55seaborn_graphing_present Page 5 of 13http://localhost:8888/nbconvert/html/Desktop/UW/2019%20spring/CSE180/seaborn_graphing_present.ipynb?download=false In [7]: # Violinplot ax = sns.violinplot(x="day", y="total_bill", data=tips, hue="smoker") In [8]: # Violinplot ax = sns.violinplot(x="day", y="total_bill", data=tips, hue="smoker", split=True, palette="bright")
  • 6. 6/17/19, 21)55seaborn_graphing_present Page 6 of 13http://localhost:8888/nbconvert/html/Desktop/UW/2019%20spring/CSE180/seaborn_graphing_present.ipynb?download=false In [9]: # Violinplot fig , ax = plt.subplots(figsize=(20,10)) ax = sns.violinplot(x="day", y="total_bill", data=tips, hue="smoker", split=True, palette="bright", inner="stick", bw=0.2, ax=ax ) In [10]: ax = sns.swarmplot(x="day", y="total_bill", hue="smoker", data=tips, p alette="Set2")
  • 7. 6/17/19, 21)55seaborn_graphing_present Page 7 of 13http://localhost:8888/nbconvert/html/Desktop/UW/2019%20spring/CSE180/seaborn_graphing_present.ipynb?download=false A note on color palettes Seaborn uses Color Brewer sets. This is a cool tool for finding a good (color blind/grayscale friendly). http://colorbrewer2.org (http://colorbrewer2.org) In [11]: # Combine a Violinplot and Swarmplot fig , ax = plt.subplots(figsize=(15,10)) ax = sns.violinplot(x="day", y="total_bill", data=tips, inner=None) ax = sns.swarmplot(x="day", y="total_bill", data=tips, color="white", edgecolor="gray", ax=ax) Distribution Plots jointplot - two variables pairplot - grid comparing two-way relationships
  • 8. 6/17/19, 21)55seaborn_graphing_present Page 8 of 13http://localhost:8888/nbconvert/html/Desktop/UW/2019%20spring/CSE180/seaborn_graphing_present.ipynb?download=false In [12]: g = sns.jointplot(x="total_bill", y="tip", data=tips)
  • 9. 6/17/19, 21)55seaborn_graphing_present Page 9 of 13http://localhost:8888/nbconvert/html/Desktop/UW/2019%20spring/CSE180/seaborn_graphing_present.ipynb?download=false In [13]: g = sns.jointplot("total_bill", "tip", data=tips, kind="reg")
  • 10. 6/17/19, 21)55seaborn_graphing_present Page 10 of 13http://localhost:8888/nbconvert/html/Desktop/UW/2019%20spring/CSE180/seaborn_graphing_present.ipynb?download=false In [14]: # Distplot - makes histograms grouped = {g:iris.loc[i,'petal_length'] for g , i in iris.groupby('spe cies').groups.items()} for g , v in grouped.items(): sns.distplot(v, label=g) plt.legend() Out[14]: <matplotlib.legend.Legend at 0x1a220d9320>
  • 11. 6/17/19, 21)55seaborn_graphing_present Page 11 of 13http://localhost:8888/nbconvert/html/Desktop/UW/2019%20spring/CSE180/seaborn_graphing_present.ipynb?download=false In [15]: # pairplot - look at all pairwise relationships g = sns.pairplot(iris)
  • 12. 6/17/19, 21)55seaborn_graphing_present Page 12 of 13http://localhost:8888/nbconvert/html/Desktop/UW/2019%20spring/CSE180/seaborn_graphing_present.ipynb?download=false In [16]: # pairplot - look at all pairwise relationships g = sns.pairplot(iris, hue='species', palette='husl')
  • 13. 6/17/19, 21)55seaborn_graphing_present Page 13 of 13http://localhost:8888/nbconvert/html/Desktop/UW/2019%20spring/CSE180/seaborn_graphing_present.ipynb?download=false In [17]: # lmplot - plots regplots across multiple variables g = sns.lmplot(x='sepal_length', y='sepal_width', hue='species', data= iris, palette='Dark2') In [ ]: