SlideShare a Scribd company logo
Prepared by Volkan OBAN
ggplot2 Examples:
1-
students = read.csv("student.csv")
library(ggplot2)
ggplot(students, aes(x = Height)) + geom_dotplot()
2-
ggplot(students, aes(x = Sex, y = Height)) + geom_boxplot() + coord_flip()
3-
ggplot(students,aes(x =Sleep)) +geom_dotplot(dotsize=0.4)
4-
ggplot(students,aes(x =Sleep)) +geom_dotplot(dotsize=0.4) + facet_grid(Level ~.)
5-
ggplot(students, aes(x = Major, y = MilesHome)) + geom_boxplot() +
coord_fip()
qplot
6-
qplot(color, price / carat, data = diamonds, geom = "jitter")
7-
qplot(color, price / carat, data = diamonds, geom = "boxplot")
8-
qplot(carat, data = diamonds, geom = "histogram", fill = color)
9-
>library(nlme)
> data(Oxboys)
> p <- ggplot(Oxboys, aes(age, height, group = Subject)) +
+ geom_line()
> p
> p + geom_smooth(aes(group = Subject), method="lm", se = F)
10-
depth_dist<- ggplot(diamonds,aes(depth)) +xlim(58,68) depth_dist+ geom_histogram(aes(y=
..density..),binwidth= 0.1) + facet_grid(cut~ .) depth_dist+ geom_histogram(aes(fill =cut),
binwidth= 0.1, position= "fill") depth_dist+geom_freqpoly(aes(y=..density..,colour= cut),
binwidth= 0.1)
Reference: http://www.stat.wisc.edu/~larget/stat302/chap2.pdf
Reference book: ggplot2 Elegant Graphics for Data Analysis; Wickham, Hadley
11-
> library("ggplot2")
> library("ggthemes")
> ggplot(diamonds, aes(x = clarity, fill = cut)) +
geom_bar() + scale_fill_ptol() +theme_minimal()
12- > dtemp <- data.frame(months = factor(rep(substr(month.name,1,3), 4), l
evels = substr(month.name,1,3)),
city = rep(c("Tokyo", "New York", "Berlin", "London"), each = 12),
temp = c(7.0, 6.9, 9.5, 14.5, 18.2, 21.5, 25.2, 26.5, 23.3, 18.3, 13.9, 9.6
, -0.2, 0.8, 5.7, 11.3, 17.0, 22.0, 24.8, 24.1, 20.1, 14.1, 8.6, 2.5,
-0.9, 0.6, 3.5, 8.4, 13.5, 17.0, 18.6, 17.9, 14.3, 9.0, 3.9, 1.0,
3.9, 4.2, 5.7, 8.5, 11.9, 15.2, 17.0, 16.6, 14.2, 10.3, 6.6, 4.8))
> ggplot(dtemp, aes(x = months, y = temp, group = city, color = city)) +
geom_line() +
geom_point(size = 1.1) +
ggtitle("Monthly Average Temperature") +
theme_hc() +
scale_colour_hc()
> ggplot(dtemp, aes(x = months, y = temp, group = city, color = city)) +
geom_line() +
geom_point(size = 1.1) +
ggtitle("Monthly Average Temperature") +
theme_hc(bgcolor = "darkunica") +
scale_fill_hc("darkunica")
Ref: https://cran.r-project.org/web/packages/ggthemes/vignettes/ggthemes.html
13-
> ppc <- ggplot(data = diamonds, aes(x = color, y = price/carat))
> ppc + geom_boxplot(aes(fill = color))
Ref:https://www3.nd.edu/~steve/computing_with_data/11_geom_examples/ggplot_examples.html
14-
morph <- read.csv("Morph_for_Sato.csv")
names(morph) <- tolower(names(morph)) # make columns names lowercase
morph <- subset(morph, islandid == "Flor_Chrl") # take only one island morph <-
morph[,c("taxonorig", "sex", "wingl", "beakh", "ubeakl")] # only keep these
names(morph)[1] <- "taxon" morph <- data.frame(na.omit(morph)) # remove all rows
morph$taxon <- factor(morph$taxon) # remove extra remaining factor levels
morph$sex <- factor(morph$sex) # remove extra remaining factor levels
row.names(morph)
ggplot(morph, aes(taxon, wingl)) + geom_boxplot() + coord_flip()
Ref: http://seananderson.ca/ggplot2-FISH554/
15-
ggplot(morph, aes(sex, wingl)) + geom_violin() + facet_wrap(~taxon)
16.
library("dplyr")
> morph_quant <-
morph %>%
+ group_by(taxon) %>%
+ summarise(
+ l = quantile(wingl, 0.25)[[1]],
+ m = median(wingl),
+ u = quantile(wingl, 0.75)[[1]]) %>%
+ # re-order factor levels by median for plotting:
+ mutate(taxon = reorder(taxon, m, function(x) x))
>ggplot(morph_quant, aes(x = taxon, y = m, ymin = l, ymax = u)) +
geom_pointrange() + coord_flip() + ylab("Wing length") + xlab("")
Ref: http://seananderson.ca/ggplot2-FISH554/
17-
>library(ggplot2)
> plot2 <- qplot(color, price/carat, data = diamonds, geom = "boxplot", col
our = color)
> plot2
18-
> library(GGally)
> library(ggplot2)
>data(tips, package = "reshape")
> pm <- ggpairs(tips, mapping = aes(color = sex), columns = c("total_bill", "time", "tip"))
> pm
Ref: http://ggobi.github.io/ggally/docs.html#columns_and_mapping

More Related Content

What's hot (20)

PDF
Data visualization with multiple groups using ggplot2
Rupak Roy
 
PDF
Data visualization using the grammar of graphics
Rupak Roy
 
PDF
Geo Spatial Plot using R
Rupak Roy
 
PPTX
R
exsuns
 
DOCX
CLUSTERGRAM
Dr. Volkan OBAN
 
PPTX
Seminar psu 20.10.2013
Vyacheslav Arbuzov
 
PDF
peRm R group. Review of packages for r for market data downloading and analysis
Vyacheslav Arbuzov
 
PPTX
Seminar PSU 10.10.2014 mme
Vyacheslav Arbuzov
 
PPTX
Seminar PSU 09.04.2013 - 10.04.2013 MiFIT, Arbuzov Vyacheslav
Vyacheslav Arbuzov
 
PDF
CLIM Undergraduate Workshop: (Attachment) Performing Extreme Value Analysis (...
The Statistical and Applied Mathematical Sciences Institute
 
PDF
Perm winter school 2014.01.31
Vyacheslav Arbuzov
 
PDF
CLIM Undergraduate Workshop: Tutorial on R Software - Huang Huang, Oct 23, 2017
The Statistical and Applied Mathematical Sciences Institute
 
KEY
R meets Hadoop
Hidekazu Tanaka
 
TXT
Script jantung copy
Nurwahidah Abidin
 
PDF
NumPy Refresher
Lukasz Dobrzanski
 
TXT
Mpibhseguranca3
JOSE PEREIRA COELHO
 
PDF
CUDA First Programs: Computer Architecture CSE448 : UAA Alaska : Notes
Subhajit Sahu
 
PDF
Numpy python cheat_sheet
Nishant Upadhyay
 
PDF
Chapter 1 Basic Concepts
Hareem Aslam
 
PDF
Py lecture5 python plots
Yoshiki Satotani
 
Data visualization with multiple groups using ggplot2
Rupak Roy
 
Data visualization using the grammar of graphics
Rupak Roy
 
Geo Spatial Plot using R
Rupak Roy
 
CLUSTERGRAM
Dr. Volkan OBAN
 
Seminar psu 20.10.2013
Vyacheslav Arbuzov
 
peRm R group. Review of packages for r for market data downloading and analysis
Vyacheslav Arbuzov
 
Seminar PSU 10.10.2014 mme
Vyacheslav Arbuzov
 
Seminar PSU 09.04.2013 - 10.04.2013 MiFIT, Arbuzov Vyacheslav
Vyacheslav Arbuzov
 
CLIM Undergraduate Workshop: (Attachment) Performing Extreme Value Analysis (...
The Statistical and Applied Mathematical Sciences Institute
 
Perm winter school 2014.01.31
Vyacheslav Arbuzov
 
CLIM Undergraduate Workshop: Tutorial on R Software - Huang Huang, Oct 23, 2017
The Statistical and Applied Mathematical Sciences Institute
 
R meets Hadoop
Hidekazu Tanaka
 
Script jantung copy
Nurwahidah Abidin
 
NumPy Refresher
Lukasz Dobrzanski
 
Mpibhseguranca3
JOSE PEREIRA COELHO
 
CUDA First Programs: Computer Architecture CSE448 : UAA Alaska : Notes
Subhajit Sahu
 
Numpy python cheat_sheet
Nishant Upadhyay
 
Chapter 1 Basic Concepts
Hareem Aslam
 
Py lecture5 python plots
Yoshiki Satotani
 

Viewers also liked (7)

PDF
Introduction to R Graphics with ggplot2
izahn
 
PDF
Data Visualization With R
Rsquared Academy
 
PPTX
Data Visualization in R
Sophia Banton
 
PPTX
Mini Innovation Lab: Community Foundations and Shared Data
Beth Kanter
 
PPTX
R and Visualization: A match made in Heaven
Edureka!
 
PDF
ggplot2用例集 入門編
nocchi_airport
 
PPT
Free Download Powerpoint Slides
George
 
Introduction to R Graphics with ggplot2
izahn
 
Data Visualization With R
Rsquared Academy
 
Data Visualization in R
Sophia Banton
 
Mini Innovation Lab: Community Foundations and Shared Data
Beth Kanter
 
R and Visualization: A match made in Heaven
Edureka!
 
ggplot2用例集 入門編
nocchi_airport
 
Free Download Powerpoint Slides
George
 
Ad

Similar to R-ggplot2 package Examples (20)

PPTX
Exploratory Analysis Part1 Coursera DataScience Specialisation
Wesley Goi
 
PPTX
Tech talk ggplot2
jalle6
 
DOCX
Genomic Graphics
Dr. Volkan OBAN
 
PDF
ggplot2: An Extensible Platform for Publication-quality Graphics
Claus Wilke
 
PDF
r for data science 2. grammar of graphics (ggplot2) clean -ref
Min-hyung Kim
 
PPTX
La R Users Group Survey Of R Graphics
guest43ed8709
 
PDF
Introduction to search and optimisation for the design theorist
Akin Osman Kazakci
 
PDF
data-visualization.pdf
Juan José Rivas
 
PDF
第13回数学カフェ「素数!!」二次会 LT資料「乱数!!」
Ken'ichi Matsui
 
PDF
Rのスコープとフレームと環境と
Takeshi Arabiki
 
KEY
ggplot2できれいなグラフ
Daisuke Ichikawa
 
PDF
Generative AdvDeep Learning: Generative Adversarial Network 2ersarial Network 2
Teslim Olayiwola
 
PDF
Download full ebook of Datacamp Ggplot2 Cheatsheet Itebooks instant download pdf
miatalafeer
 
PPTX
Data and donuts: Data Visualization using R
C. Tobin Magle
 
PDF
Algebra 2 Section 5-1
Jimbo Lamb
 
PDF
Matplotlib demo code
pythonsd
 
PDF
Functional JS for everyone - 4Developers
Bartek Witczak
 
PDF
Generalized Reinforcement Learning
Po-Hsiang (Barnett) Chiu
 
PDF
Meetup Analytics with R and Neo4j
Neo4j
 
PDF
数学カフェ 確率・統計・機械学習回 「速習 確率・統計」
Ken'ichi Matsui
 
Exploratory Analysis Part1 Coursera DataScience Specialisation
Wesley Goi
 
Tech talk ggplot2
jalle6
 
Genomic Graphics
Dr. Volkan OBAN
 
ggplot2: An Extensible Platform for Publication-quality Graphics
Claus Wilke
 
r for data science 2. grammar of graphics (ggplot2) clean -ref
Min-hyung Kim
 
La R Users Group Survey Of R Graphics
guest43ed8709
 
Introduction to search and optimisation for the design theorist
Akin Osman Kazakci
 
data-visualization.pdf
Juan José Rivas
 
第13回数学カフェ「素数!!」二次会 LT資料「乱数!!」
Ken'ichi Matsui
 
Rのスコープとフレームと環境と
Takeshi Arabiki
 
ggplot2できれいなグラフ
Daisuke Ichikawa
 
Generative AdvDeep Learning: Generative Adversarial Network 2ersarial Network 2
Teslim Olayiwola
 
Download full ebook of Datacamp Ggplot2 Cheatsheet Itebooks instant download pdf
miatalafeer
 
Data and donuts: Data Visualization using R
C. Tobin Magle
 
Algebra 2 Section 5-1
Jimbo Lamb
 
Matplotlib demo code
pythonsd
 
Functional JS for everyone - 4Developers
Bartek Witczak
 
Generalized Reinforcement Learning
Po-Hsiang (Barnett) Chiu
 
Meetup Analytics with R and Neo4j
Neo4j
 
数学カフェ 確率・統計・機械学習回 「速習 確率・統計」
Ken'ichi Matsui
 
Ad

More from Dr. Volkan OBAN (20)

PDF
Conference Paper:IMAGE PROCESSING AND OBJECT DETECTION APPLICATION: INSURANCE...
Dr. Volkan OBAN
 
PDF
Covid19py Python Package - Example
Dr. Volkan OBAN
 
PDF
Object detection with Python
Dr. Volkan OBAN
 
PDF
Python - Rastgele Orman(Random Forest) Parametreleri
Dr. Volkan OBAN
 
DOCX
Linear Programming wi̇th R - Examples
Dr. Volkan OBAN
 
DOCX
"optrees" package in R and examples.(optrees:finds optimal trees in weighted ...
Dr. Volkan OBAN
 
DOCX
k-means Clustering in Python
Dr. Volkan OBAN
 
DOCX
Naive Bayes Example using R
Dr. Volkan OBAN
 
DOCX
R forecasting Example
Dr. Volkan OBAN
 
DOCX
k-means Clustering and Custergram with R
Dr. Volkan OBAN
 
PDF
Data Science and its Relationship to Big Data and Data-Driven Decision Making
Dr. Volkan OBAN
 
PDF
Scikit-learn Cheatsheet-Python
Dr. Volkan OBAN
 
PDF
Python Pandas for Data Science cheatsheet
Dr. Volkan OBAN
 
PDF
Pandas,scipy,numpy cheatsheet
Dr. Volkan OBAN
 
PPTX
ReporteRs package in R. forming powerpoint documents-an example
Dr. Volkan OBAN
 
PPTX
ReporteRs package in R. forming powerpoint documents-an example
Dr. Volkan OBAN
 
DOCX
R Machine Learning packages( generally used)
Dr. Volkan OBAN
 
DOCX
treemap package in R and examples.
Dr. Volkan OBAN
 
DOCX
Mosaic plot in R.
Dr. Volkan OBAN
 
PDF
R-Data table Cheat Sheet
Dr. Volkan OBAN
 
Conference Paper:IMAGE PROCESSING AND OBJECT DETECTION APPLICATION: INSURANCE...
Dr. Volkan OBAN
 
Covid19py Python Package - Example
Dr. Volkan OBAN
 
Object detection with Python
Dr. Volkan OBAN
 
Python - Rastgele Orman(Random Forest) Parametreleri
Dr. Volkan OBAN
 
Linear Programming wi̇th R - Examples
Dr. Volkan OBAN
 
"optrees" package in R and examples.(optrees:finds optimal trees in weighted ...
Dr. Volkan OBAN
 
k-means Clustering in Python
Dr. Volkan OBAN
 
Naive Bayes Example using R
Dr. Volkan OBAN
 
R forecasting Example
Dr. Volkan OBAN
 
k-means Clustering and Custergram with R
Dr. Volkan OBAN
 
Data Science and its Relationship to Big Data and Data-Driven Decision Making
Dr. Volkan OBAN
 
Scikit-learn Cheatsheet-Python
Dr. Volkan OBAN
 
Python Pandas for Data Science cheatsheet
Dr. Volkan OBAN
 
Pandas,scipy,numpy cheatsheet
Dr. Volkan OBAN
 
ReporteRs package in R. forming powerpoint documents-an example
Dr. Volkan OBAN
 
ReporteRs package in R. forming powerpoint documents-an example
Dr. Volkan OBAN
 
R Machine Learning packages( generally used)
Dr. Volkan OBAN
 
treemap package in R and examples.
Dr. Volkan OBAN
 
Mosaic plot in R.
Dr. Volkan OBAN
 
R-Data table Cheat Sheet
Dr. Volkan OBAN
 

Recently uploaded (20)

PDF
JavaScript - Good or Bad? Tips for Google Tag Manager
📊 Markus Baersch
 
PDF
OOPs with Java_unit2.pdf. sarthak bookkk
Sarthak964187
 
PDF
apidays Singapore 2025 - Streaming Lakehouse with Kafka, Flink and Iceberg by...
apidays
 
PDF
apidays Singapore 2025 - How APIs can make - or break - trust in your AI by S...
apidays
 
PDF
Using AI/ML for Space Biology Research
VICTOR MAESTRE RAMIREZ
 
PDF
What does good look like - CRAP Brighton 8 July 2025
Jan Kierzyk
 
PPT
tuberculosiship-2106031cyyfuftufufufivifviviv
AkshaiRam
 
PDF
Product Management in HealthTech (Case Studies from SnappDoctor)
Hamed Shams
 
PDF
apidays Helsinki & North 2025 - APIs in the healthcare sector: hospitals inte...
apidays
 
PDF
Data Retrieval and Preparation Business Analytics.pdf
kayserrakib80
 
PPTX
apidays Helsinki & North 2025 - API access control strategies beyond JWT bear...
apidays
 
PPTX
Exploring Multilingual Embeddings for Italian Semantic Search: A Pretrained a...
Sease
 
PPTX
apidays Singapore 2025 - The Quest for the Greenest LLM , Jean Philippe Ehre...
apidays
 
PPTX
apidays Singapore 2025 - Designing for Change, Julie Schiller (Google)
apidays
 
PDF
Simplifying Document Processing with Docling for AI Applications.pdf
Tamanna
 
PDF
apidays Singapore 2025 - Surviving an interconnected world with API governanc...
apidays
 
PPTX
apidays Helsinki & North 2025 - Running a Successful API Program: Best Practi...
apidays
 
PDF
apidays Singapore 2025 - Trustworthy Generative AI: The Role of Observability...
apidays
 
PPTX
apidays Helsinki & North 2025 - APIs at Scale: Designing for Alignment, Trust...
apidays
 
PDF
Driving Employee Engagement in a Hybrid World.pdf
Mia scott
 
JavaScript - Good or Bad? Tips for Google Tag Manager
📊 Markus Baersch
 
OOPs with Java_unit2.pdf. sarthak bookkk
Sarthak964187
 
apidays Singapore 2025 - Streaming Lakehouse with Kafka, Flink and Iceberg by...
apidays
 
apidays Singapore 2025 - How APIs can make - or break - trust in your AI by S...
apidays
 
Using AI/ML for Space Biology Research
VICTOR MAESTRE RAMIREZ
 
What does good look like - CRAP Brighton 8 July 2025
Jan Kierzyk
 
tuberculosiship-2106031cyyfuftufufufivifviviv
AkshaiRam
 
Product Management in HealthTech (Case Studies from SnappDoctor)
Hamed Shams
 
apidays Helsinki & North 2025 - APIs in the healthcare sector: hospitals inte...
apidays
 
Data Retrieval and Preparation Business Analytics.pdf
kayserrakib80
 
apidays Helsinki & North 2025 - API access control strategies beyond JWT bear...
apidays
 
Exploring Multilingual Embeddings for Italian Semantic Search: A Pretrained a...
Sease
 
apidays Singapore 2025 - The Quest for the Greenest LLM , Jean Philippe Ehre...
apidays
 
apidays Singapore 2025 - Designing for Change, Julie Schiller (Google)
apidays
 
Simplifying Document Processing with Docling for AI Applications.pdf
Tamanna
 
apidays Singapore 2025 - Surviving an interconnected world with API governanc...
apidays
 
apidays Helsinki & North 2025 - Running a Successful API Program: Best Practi...
apidays
 
apidays Singapore 2025 - Trustworthy Generative AI: The Role of Observability...
apidays
 
apidays Helsinki & North 2025 - APIs at Scale: Designing for Alignment, Trust...
apidays
 
Driving Employee Engagement in a Hybrid World.pdf
Mia scott
 

R-ggplot2 package Examples

  • 1. Prepared by Volkan OBAN ggplot2 Examples: 1- students = read.csv("student.csv") library(ggplot2) ggplot(students, aes(x = Height)) + geom_dotplot()
  • 2. 2- ggplot(students, aes(x = Sex, y = Height)) + geom_boxplot() + coord_flip()
  • 5. 5- ggplot(students, aes(x = Major, y = MilesHome)) + geom_boxplot() + coord_fip()
  • 6. qplot 6- qplot(color, price / carat, data = diamonds, geom = "jitter")
  • 7. 7- qplot(color, price / carat, data = diamonds, geom = "boxplot")
  • 8. 8- qplot(carat, data = diamonds, geom = "histogram", fill = color)
  • 9. 9- >library(nlme) > data(Oxboys) > p <- ggplot(Oxboys, aes(age, height, group = Subject)) + + geom_line() > p > p + geom_smooth(aes(group = Subject), method="lm", se = F)
  • 10. 10- depth_dist<- ggplot(diamonds,aes(depth)) +xlim(58,68) depth_dist+ geom_histogram(aes(y= ..density..),binwidth= 0.1) + facet_grid(cut~ .) depth_dist+ geom_histogram(aes(fill =cut), binwidth= 0.1, position= "fill") depth_dist+geom_freqpoly(aes(y=..density..,colour= cut), binwidth= 0.1) Reference: http://www.stat.wisc.edu/~larget/stat302/chap2.pdf Reference book: ggplot2 Elegant Graphics for Data Analysis; Wickham, Hadley
  • 11. 11- > library("ggplot2") > library("ggthemes") > ggplot(diamonds, aes(x = clarity, fill = cut)) + geom_bar() + scale_fill_ptol() +theme_minimal()
  • 12. 12- > dtemp <- data.frame(months = factor(rep(substr(month.name,1,3), 4), l evels = substr(month.name,1,3)), city = rep(c("Tokyo", "New York", "Berlin", "London"), each = 12), temp = c(7.0, 6.9, 9.5, 14.5, 18.2, 21.5, 25.2, 26.5, 23.3, 18.3, 13.9, 9.6 , -0.2, 0.8, 5.7, 11.3, 17.0, 22.0, 24.8, 24.1, 20.1, 14.1, 8.6, 2.5, -0.9, 0.6, 3.5, 8.4, 13.5, 17.0, 18.6, 17.9, 14.3, 9.0, 3.9, 1.0, 3.9, 4.2, 5.7, 8.5, 11.9, 15.2, 17.0, 16.6, 14.2, 10.3, 6.6, 4.8)) > ggplot(dtemp, aes(x = months, y = temp, group = city, color = city)) + geom_line() + geom_point(size = 1.1) + ggtitle("Monthly Average Temperature") + theme_hc() + scale_colour_hc() > ggplot(dtemp, aes(x = months, y = temp, group = city, color = city)) + geom_line() + geom_point(size = 1.1) + ggtitle("Monthly Average Temperature") + theme_hc(bgcolor = "darkunica") + scale_fill_hc("darkunica") Ref: https://cran.r-project.org/web/packages/ggthemes/vignettes/ggthemes.html
  • 13. 13- > ppc <- ggplot(data = diamonds, aes(x = color, y = price/carat)) > ppc + geom_boxplot(aes(fill = color)) Ref:https://www3.nd.edu/~steve/computing_with_data/11_geom_examples/ggplot_examples.html
  • 14. 14- morph <- read.csv("Morph_for_Sato.csv") names(morph) <- tolower(names(morph)) # make columns names lowercase morph <- subset(morph, islandid == "Flor_Chrl") # take only one island morph <- morph[,c("taxonorig", "sex", "wingl", "beakh", "ubeakl")] # only keep these names(morph)[1] <- "taxon" morph <- data.frame(na.omit(morph)) # remove all rows morph$taxon <- factor(morph$taxon) # remove extra remaining factor levels morph$sex <- factor(morph$sex) # remove extra remaining factor levels row.names(morph) ggplot(morph, aes(taxon, wingl)) + geom_boxplot() + coord_flip() Ref: http://seananderson.ca/ggplot2-FISH554/
  • 15. 15- ggplot(morph, aes(sex, wingl)) + geom_violin() + facet_wrap(~taxon)
  • 16. 16. library("dplyr") > morph_quant <- morph %>% + group_by(taxon) %>% + summarise( + l = quantile(wingl, 0.25)[[1]], + m = median(wingl), + u = quantile(wingl, 0.75)[[1]]) %>% + # re-order factor levels by median for plotting: + mutate(taxon = reorder(taxon, m, function(x) x)) >ggplot(morph_quant, aes(x = taxon, y = m, ymin = l, ymax = u)) + geom_pointrange() + coord_flip() + ylab("Wing length") + xlab("") Ref: http://seananderson.ca/ggplot2-FISH554/
  • 17. 17- >library(ggplot2) > plot2 <- qplot(color, price/carat, data = diamonds, geom = "boxplot", col our = color) > plot2
  • 18. 18- > library(GGally) > library(ggplot2) >data(tips, package = "reshape") > pm <- ggpairs(tips, mapping = aes(color = sex), columns = c("total_bill", "time", "tip")) > pm Ref: http://ggobi.github.io/ggally/docs.html#columns_and_mapping