SlideShare a Scribd company logo
1 of 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

More Related Content

What's hot

"Introduction to Data Visualization" Workshop for General Assembly by Hunter ...
"Introduction to Data Visualization" Workshop for General Assembly by Hunter ..."Introduction to Data Visualization" Workshop for General Assembly by Hunter ...
"Introduction to Data Visualization" Workshop for General Assembly by Hunter ...Hunter Whitney
 
Data structures and algorithms short note (version 14).pd
Data structures and algorithms short note (version 14).pdData structures and algorithms short note (version 14).pd
Data structures and algorithms short note (version 14).pdNimmi Weeraddana
 
Data visualization in a Nutshell
Data visualization in a NutshellData visualization in a Nutshell
Data visualization in a NutshellWingChan46
 
Data Visualization in Exploratory Data Analysis
Data Visualization in Exploratory Data AnalysisData Visualization in Exploratory Data Analysis
Data Visualization in Exploratory Data AnalysisEva Durall
 
The Future Of Data Visualization
The Future Of Data VisualizationThe Future Of Data Visualization
The Future Of Data VisualizationFITC
 
Basics & asymptotic notations
Basics & asymptotic notationsBasics & asymptotic notations
Basics & asymptotic notationsRajendran
 
Binary Search Tree
Binary Search TreeBinary Search Tree
Binary Search TreeZafar Ayub
 
Mathematics, Machine Learning and ML Engineering
Mathematics, Machine Learning and ML EngineeringMathematics, Machine Learning and ML Engineering
Mathematics, Machine Learning and ML EngineeringGopi Krishna Nuti
 
Descriptive Statistics with R
Descriptive Statistics with RDescriptive Statistics with R
Descriptive Statistics with RKazuki Yoshida
 
The Difference between HTML, XHTML & HTML5 for Beginners
The Difference between HTML, XHTML & HTML5 for BeginnersThe Difference between HTML, XHTML & HTML5 for Beginners
The Difference between HTML, XHTML & HTML5 for BeginnersRasin Bekkevold
 
Breadth first search and depth first search
Breadth first search and  depth first searchBreadth first search and  depth first search
Breadth first search and depth first searchHossain Md Shakhawat
 
Introduction to data analysis using excel
Introduction to data analysis using excelIntroduction to data analysis using excel
Introduction to data analysis using excelAhmed Essam
 
Missing data
Missing dataMissing data
Missing datamandava57
 

What's hot (20)

"Introduction to Data Visualization" Workshop for General Assembly by Hunter ...
"Introduction to Data Visualization" Workshop for General Assembly by Hunter ..."Introduction to Data Visualization" Workshop for General Assembly by Hunter ...
"Introduction to Data Visualization" Workshop for General Assembly by Hunter ...
 
Data Visualization.pptx
Data Visualization.pptxData Visualization.pptx
Data Visualization.pptx
 
Data structures and algorithms short note (version 14).pd
Data structures and algorithms short note (version 14).pdData structures and algorithms short note (version 14).pd
Data structures and algorithms short note (version 14).pd
 
Data visualization in a Nutshell
Data visualization in a NutshellData visualization in a Nutshell
Data visualization in a Nutshell
 
Data Visualization in Exploratory Data Analysis
Data Visualization in Exploratory Data AnalysisData Visualization in Exploratory Data Analysis
Data Visualization in Exploratory Data Analysis
 
The Future Of Data Visualization
The Future Of Data VisualizationThe Future Of Data Visualization
The Future Of Data Visualization
 
Basics & asymptotic notations
Basics & asymptotic notationsBasics & asymptotic notations
Basics & asymptotic notations
 
Binary Search Tree
Binary Search TreeBinary Search Tree
Binary Search Tree
 
Data Visualization
Data VisualizationData Visualization
Data Visualization
 
Mathematics, Machine Learning and ML Engineering
Mathematics, Machine Learning and ML EngineeringMathematics, Machine Learning and ML Engineering
Mathematics, Machine Learning and ML Engineering
 
Descriptive Statistics with R
Descriptive Statistics with RDescriptive Statistics with R
Descriptive Statistics with R
 
Data Visualization
Data VisualizationData Visualization
Data Visualization
 
Getting Started with R
Getting Started with RGetting Started with R
Getting Started with R
 
Topological Sort
Topological SortTopological Sort
Topological Sort
 
The Difference between HTML, XHTML & HTML5 for Beginners
The Difference between HTML, XHTML & HTML5 for BeginnersThe Difference between HTML, XHTML & HTML5 for Beginners
The Difference between HTML, XHTML & HTML5 for Beginners
 
Breadth first search and depth first search
Breadth first search and  depth first searchBreadth first search and  depth first search
Breadth first search and depth first search
 
Introduction to data analysis using excel
Introduction to data analysis using excelIntroduction to data analysis using excel
Introduction to data analysis using excel
 
Missing data
Missing dataMissing data
Missing data
 
DDA algorithm
DDA algorithmDDA algorithm
DDA algorithm
 
Introduction to Data Science
Introduction to Data ScienceIntroduction to Data Science
Introduction to Data Science
 

Similar to Grammar of Graphics - Darya Vanichkina

Data visualization-2.1
Data visualization-2.1Data visualization-2.1
Data visualization-2.1RenukaRajmohan
 
Data Visualization with ggplot2.pdf
Data Visualization with ggplot2.pdfData Visualization with ggplot2.pdf
Data Visualization with ggplot2.pdfCarlosTrujillo199971
 
{tidygraph}と{ggraph}によるモダンなネットワーク分析
{tidygraph}と{ggraph}によるモダンなネットワーク分析{tidygraph}と{ggraph}によるモダンなネットワーク分析
{tidygraph}と{ggraph}によるモダンなネットワーク分析Takashi Kitano
 
Stata cheat sheet: data visualization
Stata cheat sheet: data visualizationStata cheat sheet: data visualization
Stata cheat sheet: data visualizationTim Essam
 
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 -refMin-hyung Kim
 
Stata cheat sheet: Data visualization
Stata cheat sheet: Data visualizationStata cheat sheet: Data visualization
Stata cheat sheet: Data visualizationLaura Hughes
 
{tidygraph}と{ggraph}による モダンなネットワーク分析(未公開ver)
{tidygraph}と{ggraph}による モダンなネットワーク分析(未公開ver){tidygraph}と{ggraph}による モダンなネットワーク分析(未公開ver)
{tidygraph}と{ggraph}による モダンなネットワーク分析(未公開ver)Takashi Kitano
 
Lectures r-graphics
Lectures r-graphicsLectures r-graphics
Lectures r-graphicsetyca
 
Exploratory data analysis using r
Exploratory data analysis using rExploratory data analysis using r
Exploratory data analysis using rTahera Shaikh
 
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 GraphicsClaus Wilke
 
Q plot tutorial
Q plot tutorialQ plot tutorial
Q plot tutorialAbhik Seal
 

Similar to 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
 

More from Darya Vanichkina

Sharing & Reusing Training Materials
Sharing & Reusing Training MaterialsSharing & Reusing Training Materials
Sharing & Reusing Training MaterialsDarya Vanichkina
 
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...Darya Vanichkina
 
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 revolutionDarya Vanichkina
 
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...Darya Vanichkina
 
Comparing the early ciRNA papers
Comparing the early ciRNA papers Comparing the early ciRNA papers
Comparing the early ciRNA papers Darya Vanichkina
 

More from 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
 

Recently uploaded

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
 
Log Analysis using OSSEC sasoasasasas.pptx
Log Analysis using OSSEC sasoasasasas.pptxLog Analysis using OSSEC sasoasasasas.pptx
Log Analysis using OSSEC sasoasasasas.pptxJohnnyPlasten
 
04242024_CCC TUG_Joins and Relationships
04242024_CCC TUG_Joins and Relationships04242024_CCC TUG_Joins and Relationships
04242024_CCC TUG_Joins and Relationshipsccctableauusergroup
 
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.pptxolyaivanovalion
 
RA-11058_IRR-COMPRESS Do 198 series of 1998
RA-11058_IRR-COMPRESS Do 198 series of 1998RA-11058_IRR-COMPRESS Do 198 series of 1998
RA-11058_IRR-COMPRESS Do 198 series of 1998YohFuh
 
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.pptxolyaivanovalion
 
Delhi Call Girls CP 9711199171 ☎✔👌✔ Whatsapp Hard And Sexy Vip Call
Delhi Call Girls CP 9711199171 ☎✔👌✔ Whatsapp Hard And Sexy Vip CallDelhi Call Girls CP 9711199171 ☎✔👌✔ Whatsapp Hard And Sexy Vip Call
Delhi Call Girls CP 9711199171 ☎✔👌✔ Whatsapp Hard And Sexy Vip Callshivangimorya083
 
Midocean dropshipping via API with DroFx
Midocean dropshipping via API with DroFxMidocean dropshipping via API with DroFx
Midocean dropshipping via API with DroFxolyaivanovalion
 
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.pptxolyaivanovalion
 
Delhi Call Girls Punjabi Bagh 9711199171 ☎✔👌✔ Whatsapp Hard And Sexy Vip Call
Delhi Call Girls Punjabi Bagh 9711199171 ☎✔👌✔ Whatsapp Hard And Sexy Vip CallDelhi Call Girls Punjabi Bagh 9711199171 ☎✔👌✔ Whatsapp Hard And Sexy Vip Call
Delhi Call Girls Punjabi Bagh 9711199171 ☎✔👌✔ Whatsapp Hard And Sexy Vip Callshivangimorya083
 
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
 
Week-01-2.ppt BBB human Computer interaction
Week-01-2.ppt BBB human Computer interactionWeek-01-2.ppt BBB human Computer interaction
Week-01-2.ppt BBB human Computer interactionfulawalesam
 
B2 Creative Industry Response Evaluation.docx
B2 Creative Industry Response Evaluation.docxB2 Creative Industry Response Evaluation.docx
B2 Creative Industry Response Evaluation.docxStephen266013
 
BabyOno dropshipping via API with DroFx.pptx
BabyOno dropshipping via API with DroFx.pptxBabyOno dropshipping via API with DroFx.pptx
BabyOno dropshipping via API with DroFx.pptxolyaivanovalion
 
Halmar dropshipping via API with DroFx
Halmar  dropshipping  via API with DroFxHalmar  dropshipping  via API with DroFx
Halmar dropshipping via API with DroFxolyaivanovalion
 
100-Concepts-of-AI by Anupama Kate .pptx
100-Concepts-of-AI by Anupama Kate .pptx100-Concepts-of-AI by Anupama Kate .pptx
100-Concepts-of-AI by Anupama Kate .pptxAnupama Kate
 
Smarteg dropshipping via API with DroFx.pptx
Smarteg dropshipping via API with DroFx.pptxSmarteg dropshipping via API with DroFx.pptx
Smarteg dropshipping via API with DroFx.pptxolyaivanovalion
 
Schema on read is obsolete. Welcome metaprogramming..pdf
Schema on read is obsolete. Welcome metaprogramming..pdfSchema on read is obsolete. Welcome metaprogramming..pdf
Schema on read is obsolete. Welcome metaprogramming..pdfLars Albertsson
 
Invezz.com - Grow your wealth with trading signals
Invezz.com - Grow your wealth with trading signalsInvezz.com - Grow your wealth with trading signals
Invezz.com - Grow your wealth with trading signalsInvezz1
 

Recently uploaded (20)

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
 
Log Analysis using OSSEC sasoasasasas.pptx
Log Analysis using OSSEC sasoasasasas.pptxLog Analysis using OSSEC sasoasasasas.pptx
Log Analysis using OSSEC sasoasasasas.pptx
 
Delhi 99530 vip 56974 Genuine Escort Service Call Girls in Kishangarh
Delhi 99530 vip 56974 Genuine Escort Service Call Girls in  KishangarhDelhi 99530 vip 56974 Genuine Escort Service Call Girls in  Kishangarh
Delhi 99530 vip 56974 Genuine Escort Service Call Girls in Kishangarh
 
04242024_CCC TUG_Joins and Relationships
04242024_CCC TUG_Joins and Relationships04242024_CCC TUG_Joins and Relationships
04242024_CCC TUG_Joins and Relationships
 
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
 
RA-11058_IRR-COMPRESS Do 198 series of 1998
RA-11058_IRR-COMPRESS Do 198 series of 1998RA-11058_IRR-COMPRESS Do 198 series of 1998
RA-11058_IRR-COMPRESS Do 198 series of 1998
 
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
 
Delhi Call Girls CP 9711199171 ☎✔👌✔ Whatsapp Hard And Sexy Vip Call
Delhi Call Girls CP 9711199171 ☎✔👌✔ Whatsapp Hard And Sexy Vip CallDelhi Call Girls CP 9711199171 ☎✔👌✔ Whatsapp Hard And Sexy Vip Call
Delhi Call Girls CP 9711199171 ☎✔👌✔ Whatsapp Hard And Sexy Vip Call
 
Midocean dropshipping via API with DroFx
Midocean dropshipping via API with DroFxMidocean dropshipping via API with DroFx
Midocean dropshipping via API with DroFx
 
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
 
Delhi Call Girls Punjabi Bagh 9711199171 ☎✔👌✔ Whatsapp Hard And Sexy Vip Call
Delhi Call Girls Punjabi Bagh 9711199171 ☎✔👌✔ Whatsapp Hard And Sexy Vip CallDelhi Call Girls Punjabi Bagh 9711199171 ☎✔👌✔ Whatsapp Hard And Sexy Vip Call
Delhi Call Girls Punjabi Bagh 9711199171 ☎✔👌✔ Whatsapp Hard And Sexy Vip Call
 
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
 
Week-01-2.ppt BBB human Computer interaction
Week-01-2.ppt BBB human Computer interactionWeek-01-2.ppt BBB human Computer interaction
Week-01-2.ppt BBB human Computer interaction
 
B2 Creative Industry Response Evaluation.docx
B2 Creative Industry Response Evaluation.docxB2 Creative Industry Response Evaluation.docx
B2 Creative Industry Response Evaluation.docx
 
BabyOno dropshipping via API with DroFx.pptx
BabyOno dropshipping via API with DroFx.pptxBabyOno dropshipping via API with DroFx.pptx
BabyOno 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
 
100-Concepts-of-AI by Anupama Kate .pptx
100-Concepts-of-AI by Anupama Kate .pptx100-Concepts-of-AI by Anupama Kate .pptx
100-Concepts-of-AI by Anupama Kate .pptx
 
Smarteg dropshipping via API with DroFx.pptx
Smarteg dropshipping via API with DroFx.pptxSmarteg dropshipping via API with DroFx.pptx
Smarteg dropshipping via API with DroFx.pptx
 
Schema on read is obsolete. Welcome metaprogramming..pdf
Schema on read is obsolete. Welcome metaprogramming..pdfSchema on read is obsolete. Welcome metaprogramming..pdf
Schema on read is obsolete. Welcome metaprogramming..pdf
 
Invezz.com - Grow your wealth with trading signals
Invezz.com - Grow your wealth with trading signalsInvezz.com - Grow your wealth with trading signals
Invezz.com - Grow your wealth with trading signals
 

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