SlideShare ist ein Scribd-Unternehmen logo
1 von 35
The Grammar of Graphics
Darya Vanichkina
… a personal commentary/interpretation of …
http://vita.had.co.nz/papers/layered-grammar.html
Grammar
“the fundamental principles or rules of an art or science”
(OED Online 1989)
Simple case
Simple case
Components of the grammar
Data Variables of interest
Aesthetics
x-axis

y-axis
colour

fill
size

labels
alpha

shape
line width

line type
Geometries point line histogram bar boxplot
Facets columns rows
Statistics binning smoothing descriptive inferential
Coordinates cartesian fixed polar limits
Themes Not data, but important for overall impact
Adapted from DataCamp
Exploring the diamonds data
Relationship between table (width of top of
diamond relative to widest point) and price?
diamonds %>% ggplot(aes(x = table, y = price))
+ geom_point()
Relationship between carat (weight) and price?
diamonds %>% ggplot(aes(x = carat, y = price))
+ geom_point()
Relationship between carat (weight) and price?
[How many diamonds?]
diamonds %>% ggplot(aes(x = carat, y = price))
+ geom_point(alpha = 0.1)
Relationship between carat (weight) and price?
[Lots of small diamonds!]
diamonds %>% ggplot(aes(x = carat, y = price)) +
geom_hex()
Components of the grammar
Data Variables of interest
Aesthetics
x-axis

y-axis
colour

fill
size

labels
alpha

shape
line width

line type
Geometries point line histogram bar boxplot
Facets columns rows
Statistics binning smoothing descriptive inferential
Coordinates cartesian fixed polar limits
Themes Not data, but important for overall impact
Adapted from DataCamp
Relationship between clarity and price?
Worse ——————————————————> Better
diamonds %>% ggplot(aes(x = clarity, y = price)) +
geom_boxplot()
How many diamonds with each clarity?
Worse ——————————————————> Better
diamonds %>% ggplot(aes(x = clarity, fill = clarity)) +
geom_bar()
Relationship between cut and price?
Worse ——————————————————> Better
diamonds %>% ggplot(aes(x = cut, y = price)) +
geom_boxplot()
Relationship between cut and price?
Worse ——————————————————> Better
diamonds %>% ggplot(aes(x = cut, y = price)) +
geom_boxplot()
Relationship between cut and price?
Worse ——————————————————> Better
diamonds %>% ggplot(aes(x = cut, y = price)) +
geom_violin()
Components of the grammar
Data Variables of interest
Aesthetics
x-axis

y-axis
colour

fill
size

labels
alpha

shape
line width

line type
Geometries point line histogram bar boxplot
Facets columns rows
Statistics binning smoothing descriptive inferential
Coordinates cartesian fixed polar limits
Themes Not data, but important for overall impact
Adapted from DataCamp
Relationship between price and carat grouped by cut and clarity?
diamonds %>% ggplot(aes(x = carat, y = price)) + geom_point() + facet_grid(cut~clarity)
Relationship between price and carat grouped by cut and clarity (with trend)?
diamonds %>% ggplot(aes(x = carat, y = price)) + geom_point() + facet_grid(cut~clarity) + geom_smooth(method =
"lm")
Relationship between table parameter (width of top of diamond relative to
widest point, converted on the fly into a factor) and price, faceted by cut?
diamonds %>%
mutate(TableIsSmall = factor(table < median(table)))%>%
ggplot(aes(x = carat, y = price, colour = TableIsSmall)) + geom_point() + facet_grid(.~cut)
Relationship between table parameter (width of top of diamond relative to
widest point, converted on the fly into a factor) and price, faceted by cut?
diamonds %>%
mutate(TableIsSmall = factor(table < median(table)))%>%
ggplot(aes(x = carat, y = price, colour = TableIsSmall)) + geom_point() + facet_grid(.~cut)
Most diamonds with a small table (TableIsBig == FALSE) have an “Ideal” cut…
Components of the grammar
Data Variables of interest
Aesthetics
x-axis

y-axis
colour

fill
size

labels
alpha

shape
line width

line type
Geometries point line histogram bar boxplot
Facets columns rows
Statistics binning smoothing descriptive inferential
Coordinates cartesian fixed polar limits
Themes Not data, but important for overall impact
Adapted from DataCamp
Relationship between cut and price?
Worse ——————————————————> Better
diamonds %>% ggplot(aes(x = cut, y = price)) +
geom_boxplot()
Relationship between cut and price?
[log-scale]
Worse ——————————————————> Better
diamonds %>% ggplot(aes(x = cut, y = price)) +
geom_boxplot()+ scale_y_log10()
Worse ——————————————————> Better
diamonds %>% ggplot(aes(x = cut, y = price)) +
geom_boxplot()
How many diamonds with each clarity?
Worse ——————————————————> Better
diamonds %>% ggplot(aes(x = clarity, fill = clarity))+geom_bar()
How many diamonds with each clarity?
Worse ——————————————————> Better
diamonds %>% ggplot(aes(x = clarity, fill = clarity))+geom_bar() diamonds %>% ggplot(aes(x = clarity, fill = clarity))
+geom_bar(width=1) + coord_polar()
Components of the grammar
Data Variables of interest
Aesthetics
x-axis

y-axis
colour

fill
size

labels
alpha

shape
line width

line type
Geometries point line histogram bar boxplot
Facets columns rows
Statistics binning smoothing descriptive inferential
Coordinates cartesian fixed polar limits
Themes Not data, but important for overall impact
Adapted from DataCamp
Finishing up with the diamonds data
diamonds %>% ggplot(aes(x = carat, y = price)) +
geom_point() + facet_grid(cut~clarity,
scales = "free_x") + geom_smooth(method = “lm")
diamonds %>% ggplot(aes(x = cut, y = price))
+ geom_boxplot()+ scale_y_log10()
Finishing up with the diamonds data
diamonds %>% ggplot(aes(x = carat, y = price)) +
geom_point() + facet_grid(cut~clarity,
scales = "free_x") + geom_smooth(method = "lm") + theme_bw()
diamonds %>% ggplot(aes(x = cut, y = price))
+ geom_boxplot()+ scale_y_log10() + theme_minimal()
Just changing the themediamonds %>% ggplot(aes(x = carat, y = price)) +
geom_point(col = "red") + facet_grid(cut~clarity,
scales = "free_x") + geom_smooth(method = "lm") +
theme_black()
diamonds %>% ggplot(aes(x = cut, y = price))
+ geom_boxplot()+ scale_y_log10() + theme_dark()
The Grammar of Graphics
Data Variables of interest
Aesthetics
x-axis

y-axis
colour

fill
size

labels
alpha

shape
line width

line type
Geometries point line histogram bar boxplot
Facets columns rows
Statistics binning smoothing descriptive inferential
Coordinates cartesian fixed polar limits
Themes Not data, but important for overall impact
Limitations
Limitations
https://www.andrewheiss.com/blog/2017/08/10/exploring-minards-1812-plot-with-ggplot2/
The Grammar of Graphics
Data Variables of interest
Aesthetics
x-axis

y-axis
colour

fill
size

labels
alpha

shape
line width

line type
Geometries point line histogram bar boxplot
Facets columns rows
Statistics binning smoothing descriptive inferential
Coordinates cartesian fixed polar limits
Themes Not data, but important for overall impact
https://github.com/dvanic/18ResBazPresentation

Weitere ähnliche Inhalte

Was ist angesagt?

Introduction to Deep Learning, Keras, and TensorFlow
Introduction to Deep Learning, Keras, and TensorFlowIntroduction to Deep Learning, Keras, and TensorFlow
Introduction to Deep Learning, Keras, and TensorFlow
Sri Ambati
 
Machine Learning vs Deep Learning vs Artificial Intelligence | ML vs DL vs AI...
Machine Learning vs Deep Learning vs Artificial Intelligence | ML vs DL vs AI...Machine Learning vs Deep Learning vs Artificial Intelligence | ML vs DL vs AI...
Machine Learning vs Deep Learning vs Artificial Intelligence | ML vs DL vs AI...
Simplilearn
 
[NDC 14] 가죽 장화를 먹게 해달라니 - &lt;야생의>의 자유도 높은 아이템 시스템 구현
[NDC 14] 가죽 장화를 먹게 해달라니 - &lt;야생의>의 자유도 높은 아이템 시스템 구현[NDC 14] 가죽 장화를 먹게 해달라니 - &lt;야생의>의 자유도 높은 아이템 시스템 구현
[NDC 14] 가죽 장화를 먹게 해달라니 - &lt;야생의>의 자유도 높은 아이템 시스템 구현
Hoyoung Choi
 
테일즈위버 합성 시스템 역 기획
테일즈위버 합성 시스템 역 기획테일즈위버 합성 시스템 역 기획
테일즈위버 합성 시스템 역 기획
Jun Geun Lee
 
전형규, 프로젝트DH의 절차적 애니메이션 시스템, NDC2017
전형규, 프로젝트DH의 절차적 애니메이션 시스템, NDC2017전형규, 프로젝트DH의 절차적 애니메이션 시스템, NDC2017
전형규, 프로젝트DH의 절차적 애니메이션 시스템, NDC2017
devCAT Studio, NEXON
 

Was ist angesagt? (20)

Introduction to Deep Learning, Keras, and TensorFlow
Introduction to Deep Learning, Keras, and TensorFlowIntroduction to Deep Learning, Keras, and TensorFlow
Introduction to Deep Learning, Keras, and TensorFlow
 
[부스트캠프 Tech Talk] 신원지_Wandb Visualization
[부스트캠프 Tech Talk] 신원지_Wandb Visualization[부스트캠프 Tech Talk] 신원지_Wandb Visualization
[부스트캠프 Tech Talk] 신원지_Wandb Visualization
 
Visualization of Deep Learning Models (D1L6 2017 UPC Deep Learning for Comput...
Visualization of Deep Learning Models (D1L6 2017 UPC Deep Learning for Comput...Visualization of Deep Learning Models (D1L6 2017 UPC Deep Learning for Comput...
Visualization of Deep Learning Models (D1L6 2017 UPC Deep Learning for Comput...
 
Machine Learning vs Deep Learning vs Artificial Intelligence | ML vs DL vs AI...
Machine Learning vs Deep Learning vs Artificial Intelligence | ML vs DL vs AI...Machine Learning vs Deep Learning vs Artificial Intelligence | ML vs DL vs AI...
Machine Learning vs Deep Learning vs Artificial Intelligence | ML vs DL vs AI...
 
Python for data analysis
Python for data analysisPython for data analysis
Python for data analysis
 
[NDC 14] 가죽 장화를 먹게 해달라니 - &lt;야생의>의 자유도 높은 아이템 시스템 구현
[NDC 14] 가죽 장화를 먹게 해달라니 - &lt;야생의>의 자유도 높은 아이템 시스템 구현[NDC 14] 가죽 장화를 먹게 해달라니 - &lt;야생의>의 자유도 높은 아이템 시스템 구현
[NDC 14] 가죽 장화를 먹게 해달라니 - &lt;야생의>의 자유도 높은 아이템 시스템 구현
 
Guide to creation of game concept document
Guide to creation of game concept documentGuide to creation of game concept document
Guide to creation of game concept document
 
테일즈위버 합성 시스템 역 기획
테일즈위버 합성 시스템 역 기획테일즈위버 합성 시스템 역 기획
테일즈위버 합성 시스템 역 기획
 
파이콘 한국 2019 튜토리얼 - LRP (Part 2)
파이콘 한국 2019 튜토리얼 - LRP (Part 2)파이콘 한국 2019 튜토리얼 - LRP (Part 2)
파이콘 한국 2019 튜토리얼 - LRP (Part 2)
 
서비스 기획자를 위한 데이터분석 시작하기
서비스 기획자를 위한 데이터분석 시작하기서비스 기획자를 위한 데이터분석 시작하기
서비스 기획자를 위한 데이터분석 시작하기
 
Visualizing Model Selection with Scikit-Yellowbrick: An Introduction to Devel...
Visualizing Model Selection with Scikit-Yellowbrick: An Introduction to Devel...Visualizing Model Selection with Scikit-Yellowbrick: An Introduction to Devel...
Visualizing Model Selection with Scikit-Yellowbrick: An Introduction to Devel...
 
Robust MLOps with Open-Source: ModelDB, Docker, Jenkins, and Prometheus
Robust MLOps with Open-Source: ModelDB, Docker, Jenkins, and PrometheusRobust MLOps with Open-Source: ModelDB, Docker, Jenkins, and Prometheus
Robust MLOps with Open-Source: ModelDB, Docker, Jenkins, and Prometheus
 
Getting started with TensorFlow
Getting started with TensorFlowGetting started with TensorFlow
Getting started with TensorFlow
 
Low-level Shader Optimization for Next-Gen and DX11 by Emil Persson
Low-level Shader Optimization for Next-Gen and DX11 by Emil PerssonLow-level Shader Optimization for Next-Gen and DX11 by Emil Persson
Low-level Shader Optimization for Next-Gen and DX11 by Emil Persson
 
Location Intelligence: The Secret Sauce for OOH Advertising
Location Intelligence: The Secret Sauce for OOH AdvertisingLocation Intelligence: The Secret Sauce for OOH Advertising
Location Intelligence: The Secret Sauce for OOH Advertising
 
Generative Adversarial Networks
Generative Adversarial NetworksGenerative Adversarial Networks
Generative Adversarial Networks
 
KERAS Python Tutorial
KERAS Python TutorialKERAS Python Tutorial
KERAS Python Tutorial
 
전형규, 프로젝트DH의 절차적 애니메이션 시스템, NDC2017
전형규, 프로젝트DH의 절차적 애니메이션 시스템, NDC2017전형규, 프로젝트DH의 절차적 애니메이션 시스템, NDC2017
전형규, 프로젝트DH의 절차적 애니메이션 시스템, NDC2017
 
Anatomy of a Modern Game design Document - Ralf Adam, Vera Frisch - 4C:Kyiv
Anatomy of a Modern Game design Document - Ralf Adam, Vera Frisch - 4C:KyivAnatomy of a Modern Game design Document - Ralf Adam, Vera Frisch - 4C:Kyiv
Anatomy of a Modern Game design Document - Ralf Adam, Vera Frisch - 4C:Kyiv
 
LeNet-5
LeNet-5LeNet-5
LeNet-5
 

Ähnlich wie Grammar of Graphics - Darya Vanichkina

Lectures r-graphics
Lectures r-graphicsLectures r-graphics
Lectures r-graphics
etyca
 

Ähnlich wie Grammar of Graphics - Darya Vanichkina (20)

data-visualization.pdf
data-visualization.pdfdata-visualization.pdf
data-visualization.pdf
 
Ggplot2 cheatsheet-2.1
Ggplot2 cheatsheet-2.1Ggplot2 cheatsheet-2.1
Ggplot2 cheatsheet-2.1
 
Ggplot
GgplotGgplot
Ggplot
 
RBootcamp Day 4
RBootcamp Day 4RBootcamp Day 4
RBootcamp Day 4
 
Data visualization-2.1
Data visualization-2.1Data visualization-2.1
Data visualization-2.1
 
Data Visualization with ggplot2.pdf
Data Visualization with ggplot2.pdfData Visualization with ggplot2.pdf
Data Visualization with ggplot2.pdf
 
VISIALIZACION DE DATA.pdf
VISIALIZACION DE DATA.pdfVISIALIZACION DE DATA.pdf
VISIALIZACION DE DATA.pdf
 
{tidygraph}と{ggraph}によるモダンなネットワーク分析
{tidygraph}と{ggraph}によるモダンなネットワーク分析{tidygraph}と{ggraph}によるモダンなネットワーク分析
{tidygraph}と{ggraph}によるモダンなネットワーク分析
 
Stata cheat sheet: data visualization
Stata cheat sheet: data visualizationStata cheat sheet: data visualization
Stata cheat sheet: data visualization
 
r for data science 2. grammar of graphics (ggplot2) clean -ref
r for data science 2. grammar of graphics (ggplot2)  clean -refr for data science 2. grammar of graphics (ggplot2)  clean -ref
r for data science 2. grammar of graphics (ggplot2) clean -ref
 
R graphics
R graphicsR graphics
R graphics
 
Stata cheat sheet: Data visualization
Stata cheat sheet: Data visualizationStata cheat sheet: Data visualization
Stata cheat sheet: Data visualization
 
MATHS SYMBOLS.pdf
MATHS SYMBOLS.pdfMATHS SYMBOLS.pdf
MATHS SYMBOLS.pdf
 
{tidygraph}と{ggraph}による モダンなネットワーク分析(未公開ver)
{tidygraph}と{ggraph}による モダンなネットワーク分析(未公開ver){tidygraph}と{ggraph}による モダンなネットワーク分析(未公開ver)
{tidygraph}と{ggraph}による モダンなネットワーク分析(未公開ver)
 
R training5
R training5R training5
R training5
 
ML-CheatSheet (1).pdf
ML-CheatSheet (1).pdfML-CheatSheet (1).pdf
ML-CheatSheet (1).pdf
 
Lectures r-graphics
Lectures r-graphicsLectures r-graphics
Lectures r-graphics
 
Exploratory data analysis using r
Exploratory data analysis using rExploratory data analysis using r
Exploratory data analysis using r
 
ggplot2: An Extensible Platform for Publication-quality Graphics
ggplot2: An Extensible Platform for Publication-quality Graphicsggplot2: An Extensible Platform for Publication-quality Graphics
ggplot2: An Extensible Platform for Publication-quality Graphics
 
Q plot tutorial
Q plot tutorialQ plot tutorial
Q plot tutorial
 

Mehr von Darya Vanichkina

Mehr von Darya Vanichkina (6)

Sharing & Reusing Training Materials
Sharing & Reusing Training MaterialsSharing & Reusing Training Materials
Sharing & Reusing Training Materials
 
Jumping into digital: Lessons learned while moving live coding machine learni...
Jumping into digital: Lessons learned while moving live coding machine learni...Jumping into digital: Lessons learned while moving live coding machine learni...
Jumping into digital: Lessons learned while moving live coding machine learni...
 
ANDS_TrainingTheTrainer
ANDS_TrainingTheTrainerANDS_TrainingTheTrainer
ANDS_TrainingTheTrainer
 
Big data biology for pythonistas: getting in on the genomics revolution
Big data biology for pythonistas: getting in on the genomics revolutionBig data biology for pythonistas: getting in on the genomics revolution
Big data biology for pythonistas: getting in on the genomics revolution
 
Activity-dependent transcriptional dynamics in mouse primary cortical and hum...
Activity-dependent transcriptional dynamics in mouse primary cortical and hum...Activity-dependent transcriptional dynamics in mouse primary cortical and hum...
Activity-dependent transcriptional dynamics in mouse primary cortical and hum...
 
Comparing the early ciRNA papers
Comparing the early ciRNA papers Comparing the early ciRNA papers
Comparing the early ciRNA papers
 

Kürzlich hochgeladen

Call Girls Bannerghatta Road Just Call 👗 7737669865 👗 Top Class Call Girl Ser...
Call Girls Bannerghatta Road Just Call 👗 7737669865 👗 Top Class Call Girl Ser...Call Girls Bannerghatta Road Just Call 👗 7737669865 👗 Top Class Call Girl Ser...
Call Girls Bannerghatta Road Just Call 👗 7737669865 👗 Top Class Call Girl Ser...
amitlee9823
 
Junnasandra Call Girls: 🍓 7737669865 🍓 High Profile Model Escorts | Bangalore...
Junnasandra Call Girls: 🍓 7737669865 🍓 High Profile Model Escorts | Bangalore...Junnasandra Call Girls: 🍓 7737669865 🍓 High Profile Model Escorts | Bangalore...
Junnasandra Call Girls: 🍓 7737669865 🍓 High Profile Model Escorts | Bangalore...
amitlee9823
 
Vip Mumbai Call Girls Thane West Call On 9920725232 With Body to body massage...
Vip Mumbai Call Girls Thane West Call On 9920725232 With Body to body massage...Vip Mumbai Call Girls Thane West Call On 9920725232 With Body to body massage...
Vip Mumbai Call Girls Thane West Call On 9920725232 With Body to body massage...
amitlee9823
 
FESE Capital Markets Fact Sheet 2024 Q1.pdf
FESE Capital Markets Fact Sheet 2024 Q1.pdfFESE Capital Markets Fact Sheet 2024 Q1.pdf
FESE Capital Markets Fact Sheet 2024 Q1.pdf
MarinCaroMartnezBerg
 
Al Barsha Escorts $#$ O565212860 $#$ Escort Service In Al Barsha
Al Barsha Escorts $#$ O565212860 $#$ Escort Service In Al BarshaAl Barsha Escorts $#$ O565212860 $#$ Escort Service In Al Barsha
Al Barsha Escorts $#$ O565212860 $#$ Escort Service In Al Barsha
AroojKhan71
 
Call Girls In Shalimar Bagh ( Delhi) 9953330565 Escorts Service
Call Girls In Shalimar Bagh ( Delhi) 9953330565 Escorts ServiceCall Girls In Shalimar Bagh ( Delhi) 9953330565 Escorts Service
Call Girls In Shalimar Bagh ( Delhi) 9953330565 Escorts Service
9953056974 Low Rate Call Girls In Saket, Delhi NCR
 
Call Girls Indiranagar Just Call 👗 7737669865 👗 Top Class Call Girl Service B...
Call Girls Indiranagar Just Call 👗 7737669865 👗 Top Class Call Girl Service B...Call Girls Indiranagar Just Call 👗 7737669865 👗 Top Class Call Girl Service B...
Call Girls Indiranagar Just Call 👗 7737669865 👗 Top Class Call Girl Service B...
amitlee9823
 

Kürzlich hochgeladen (20)

Call Girls Bannerghatta Road Just Call 👗 7737669865 👗 Top Class Call Girl Ser...
Call Girls Bannerghatta Road Just Call 👗 7737669865 👗 Top Class Call Girl Ser...Call Girls Bannerghatta Road Just Call 👗 7737669865 👗 Top Class Call Girl Ser...
Call Girls Bannerghatta Road Just Call 👗 7737669865 👗 Top Class Call Girl Ser...
 
Junnasandra Call Girls: 🍓 7737669865 🍓 High Profile Model Escorts | Bangalore...
Junnasandra Call Girls: 🍓 7737669865 🍓 High Profile Model Escorts | Bangalore...Junnasandra Call Girls: 🍓 7737669865 🍓 High Profile Model Escorts | Bangalore...
Junnasandra Call Girls: 🍓 7737669865 🍓 High Profile Model Escorts | Bangalore...
 
ALSO dropshipping via API with DroFx.pptx
ALSO dropshipping via API with DroFx.pptxALSO dropshipping via API with DroFx.pptx
ALSO dropshipping via API with DroFx.pptx
 
Vip Mumbai Call Girls Thane West Call On 9920725232 With Body to body massage...
Vip Mumbai Call Girls Thane West Call On 9920725232 With Body to body massage...Vip Mumbai Call Girls Thane West Call On 9920725232 With Body to body massage...
Vip Mumbai Call Girls Thane West Call On 9920725232 With Body to body massage...
 
Ravak dropshipping via API with DroFx.pptx
Ravak dropshipping via API with DroFx.pptxRavak dropshipping via API with DroFx.pptx
Ravak dropshipping via API with DroFx.pptx
 
VidaXL dropshipping via API with DroFx.pptx
VidaXL dropshipping via API with DroFx.pptxVidaXL dropshipping via API with DroFx.pptx
VidaXL dropshipping via API with DroFx.pptx
 
Halmar dropshipping via API with DroFx
Halmar  dropshipping  via API with DroFxHalmar  dropshipping  via API with DroFx
Halmar dropshipping via API with DroFx
 
Digital Advertising Lecture for Advanced Digital & Social Media Strategy at U...
Digital Advertising Lecture for Advanced Digital & Social Media Strategy at U...Digital Advertising Lecture for Advanced Digital & Social Media Strategy at U...
Digital Advertising Lecture for Advanced Digital & Social Media Strategy at U...
 
Predicting Loan Approval: A Data Science Project
Predicting Loan Approval: A Data Science ProjectPredicting Loan Approval: A Data Science Project
Predicting Loan Approval: A Data Science Project
 
Edukaciniai dropshipping via API with DroFx
Edukaciniai dropshipping via API with DroFxEdukaciniai dropshipping via API with DroFx
Edukaciniai dropshipping via API with DroFx
 
Accredited-Transport-Cooperatives-Jan-2021-Web.pdf
Accredited-Transport-Cooperatives-Jan-2021-Web.pdfAccredited-Transport-Cooperatives-Jan-2021-Web.pdf
Accredited-Transport-Cooperatives-Jan-2021-Web.pdf
 
Midocean dropshipping via API with DroFx
Midocean dropshipping via API with DroFxMidocean dropshipping via API with DroFx
Midocean dropshipping via API with DroFx
 
BigBuy dropshipping via API with DroFx.pptx
BigBuy dropshipping via API with DroFx.pptxBigBuy dropshipping via API with DroFx.pptx
BigBuy dropshipping via API with DroFx.pptx
 
FESE Capital Markets Fact Sheet 2024 Q1.pdf
FESE Capital Markets Fact Sheet 2024 Q1.pdfFESE Capital Markets Fact Sheet 2024 Q1.pdf
FESE Capital Markets Fact Sheet 2024 Q1.pdf
 
Discover Why Less is More in B2B Research
Discover Why Less is More in B2B ResearchDiscover Why Less is More in B2B Research
Discover Why Less is More in B2B Research
 
Carero dropshipping via API with DroFx.pptx
Carero dropshipping via API with DroFx.pptxCarero dropshipping via API with DroFx.pptx
Carero dropshipping via API with DroFx.pptx
 
Al Barsha Escorts $#$ O565212860 $#$ Escort Service In Al Barsha
Al Barsha Escorts $#$ O565212860 $#$ Escort Service In Al BarshaAl Barsha Escorts $#$ O565212860 $#$ Escort Service In Al Barsha
Al Barsha Escorts $#$ O565212860 $#$ Escort Service In Al Barsha
 
CebaBaby dropshipping via API with DroFX.pptx
CebaBaby dropshipping via API with DroFX.pptxCebaBaby dropshipping via API with DroFX.pptx
CebaBaby dropshipping via API with DroFX.pptx
 
Call Girls In Shalimar Bagh ( Delhi) 9953330565 Escorts Service
Call Girls In Shalimar Bagh ( Delhi) 9953330565 Escorts ServiceCall Girls In Shalimar Bagh ( Delhi) 9953330565 Escorts Service
Call Girls In Shalimar Bagh ( Delhi) 9953330565 Escorts Service
 
Call Girls Indiranagar Just Call 👗 7737669865 👗 Top Class Call Girl Service B...
Call Girls Indiranagar Just Call 👗 7737669865 👗 Top Class Call Girl Service B...Call Girls Indiranagar Just Call 👗 7737669865 👗 Top Class Call Girl Service B...
Call Girls Indiranagar Just Call 👗 7737669865 👗 Top Class Call Girl Service B...
 

Grammar of Graphics - Darya Vanichkina

  • 1. The Grammar of Graphics Darya Vanichkina
  • 2. … a personal commentary/interpretation of … http://vita.had.co.nz/papers/layered-grammar.html
  • 3. Grammar “the fundamental principles or rules of an art or science” (OED Online 1989)
  • 6. Components of the grammar Data Variables of interest Aesthetics x-axis y-axis colour fill size labels alpha shape line width line type Geometries point line histogram bar boxplot Facets columns rows Statistics binning smoothing descriptive inferential Coordinates cartesian fixed polar limits Themes Not data, but important for overall impact Adapted from DataCamp
  • 8. Relationship between table (width of top of diamond relative to widest point) and price? diamonds %>% ggplot(aes(x = table, y = price)) + geom_point()
  • 9. Relationship between carat (weight) and price? diamonds %>% ggplot(aes(x = carat, y = price)) + geom_point()
  • 10. Relationship between carat (weight) and price? [How many diamonds?] diamonds %>% ggplot(aes(x = carat, y = price)) + geom_point(alpha = 0.1)
  • 11. Relationship between carat (weight) and price? [Lots of small diamonds!] diamonds %>% ggplot(aes(x = carat, y = price)) + geom_hex()
  • 12. Components of the grammar Data Variables of interest Aesthetics x-axis y-axis colour fill size labels alpha shape line width line type Geometries point line histogram bar boxplot Facets columns rows Statistics binning smoothing descriptive inferential Coordinates cartesian fixed polar limits Themes Not data, but important for overall impact Adapted from DataCamp
  • 13. Relationship between clarity and price? Worse ——————————————————> Better diamonds %>% ggplot(aes(x = clarity, y = price)) + geom_boxplot()
  • 14. How many diamonds with each clarity? Worse ——————————————————> Better diamonds %>% ggplot(aes(x = clarity, fill = clarity)) + geom_bar()
  • 15. Relationship between cut and price? Worse ——————————————————> Better diamonds %>% ggplot(aes(x = cut, y = price)) + geom_boxplot()
  • 16. Relationship between cut and price? Worse ——————————————————> Better diamonds %>% ggplot(aes(x = cut, y = price)) + geom_boxplot()
  • 17. Relationship between cut and price? Worse ——————————————————> Better diamonds %>% ggplot(aes(x = cut, y = price)) + geom_violin()
  • 18. Components of the grammar Data Variables of interest Aesthetics x-axis y-axis colour fill size labels alpha shape line width line type Geometries point line histogram bar boxplot Facets columns rows Statistics binning smoothing descriptive inferential Coordinates cartesian fixed polar limits Themes Not data, but important for overall impact Adapted from DataCamp
  • 19. Relationship between price and carat grouped by cut and clarity? diamonds %>% ggplot(aes(x = carat, y = price)) + geom_point() + facet_grid(cut~clarity)
  • 20. Relationship between price and carat grouped by cut and clarity (with trend)? diamonds %>% ggplot(aes(x = carat, y = price)) + geom_point() + facet_grid(cut~clarity) + geom_smooth(method = "lm")
  • 21. Relationship between table parameter (width of top of diamond relative to widest point, converted on the fly into a factor) and price, faceted by cut? diamonds %>% mutate(TableIsSmall = factor(table < median(table)))%>% ggplot(aes(x = carat, y = price, colour = TableIsSmall)) + geom_point() + facet_grid(.~cut)
  • 22. Relationship between table parameter (width of top of diamond relative to widest point, converted on the fly into a factor) and price, faceted by cut? diamonds %>% mutate(TableIsSmall = factor(table < median(table)))%>% ggplot(aes(x = carat, y = price, colour = TableIsSmall)) + geom_point() + facet_grid(.~cut) Most diamonds with a small table (TableIsBig == FALSE) have an “Ideal” cut…
  • 23. Components of the grammar Data Variables of interest Aesthetics x-axis y-axis colour fill size labels alpha shape line width line type Geometries point line histogram bar boxplot Facets columns rows Statistics binning smoothing descriptive inferential Coordinates cartesian fixed polar limits Themes Not data, but important for overall impact Adapted from DataCamp
  • 24. Relationship between cut and price? Worse ——————————————————> Better diamonds %>% ggplot(aes(x = cut, y = price)) + geom_boxplot()
  • 25. Relationship between cut and price? [log-scale] Worse ——————————————————> Better diamonds %>% ggplot(aes(x = cut, y = price)) + geom_boxplot()+ scale_y_log10() Worse ——————————————————> Better diamonds %>% ggplot(aes(x = cut, y = price)) + geom_boxplot()
  • 26. How many diamonds with each clarity? Worse ——————————————————> Better diamonds %>% ggplot(aes(x = clarity, fill = clarity))+geom_bar()
  • 27. How many diamonds with each clarity? Worse ——————————————————> Better diamonds %>% ggplot(aes(x = clarity, fill = clarity))+geom_bar() diamonds %>% ggplot(aes(x = clarity, fill = clarity)) +geom_bar(width=1) + coord_polar()
  • 28. Components of the grammar Data Variables of interest Aesthetics x-axis y-axis colour fill size labels alpha shape line width line type Geometries point line histogram bar boxplot Facets columns rows Statistics binning smoothing descriptive inferential Coordinates cartesian fixed polar limits Themes Not data, but important for overall impact Adapted from DataCamp
  • 29. Finishing up with the diamonds data diamonds %>% ggplot(aes(x = carat, y = price)) + geom_point() + facet_grid(cut~clarity, scales = "free_x") + geom_smooth(method = “lm") diamonds %>% ggplot(aes(x = cut, y = price)) + geom_boxplot()+ scale_y_log10()
  • 30. Finishing up with the diamonds data diamonds %>% ggplot(aes(x = carat, y = price)) + geom_point() + facet_grid(cut~clarity, scales = "free_x") + geom_smooth(method = "lm") + theme_bw() diamonds %>% ggplot(aes(x = cut, y = price)) + geom_boxplot()+ scale_y_log10() + theme_minimal()
  • 31. Just changing the themediamonds %>% ggplot(aes(x = carat, y = price)) + geom_point(col = "red") + facet_grid(cut~clarity, scales = "free_x") + geom_smooth(method = "lm") + theme_black() diamonds %>% ggplot(aes(x = cut, y = price)) + geom_boxplot()+ scale_y_log10() + theme_dark()
  • 32. The Grammar of Graphics Data Variables of interest Aesthetics x-axis y-axis colour fill size labels alpha shape line width line type Geometries point line histogram bar boxplot Facets columns rows Statistics binning smoothing descriptive inferential Coordinates cartesian fixed polar limits Themes Not data, but important for overall impact
  • 35. The Grammar of Graphics Data Variables of interest Aesthetics x-axis y-axis colour fill size labels alpha shape line width line type Geometries point line histogram bar boxplot Facets columns rows Statistics binning smoothing descriptive inferential Coordinates cartesian fixed polar limits Themes Not data, but important for overall impact https://github.com/dvanic/18ResBazPresentation