SlideShare a Scribd company logo
1 of 19
Download to read offline
There are other graphic engines available through
various R packages. They provide alternative
ways of defining graphs, contain extra
functionality, or make use of different paradigms
about the elements of plot building.
The lattice package, written by
Deepayan Sarkar, attempts to
improve on base R graphics by
providing better defaults and the
ability to easily display
multivariate relationships. In
particular, the package supports
the creation of trellis graphs -
graphs that display a variable or
the relationship between
variables, conditioned on one or
more other variables. Usage:
graph_type description formula
examples
barchart bar chart x~A or A~x
bwplot boxplot x~A or A~x
cloud 3D scatterplot z~x*y|A
contourplot 3D contour plot z~x*y
densityplot kernal density plot ~x|A*B
dotplot dotplot ~x|A
histogram histogram ~x
levelplot 3D level plot z~y*x
parallel parallel
coordinates plot
data frame
splom scatterplot matrix data frame
stripplot strip plots A~x or x~A
xyplot scatterplot y~x|A
wireframe 3D wireframe
graph
z~y*x
The lattice package, written by Deepayan Sarkar, attempts to
improve on base R graphics by providing better defaults and the
ability to easily display multivariate relationships. In particular, the
package supports the creation of trellis graphs - graphs that display
a variable or the relationship between variables, conditioned on one
or more other variables. Usage:
> data(quakes)
> head(quakes)
lat long depth mag stations
1 -20.42 181.62 562 4.8 41
2 -20.62 181.03 650 4.2 15
3 -26.00 184.10 42 5.4 43
4 -17.97 181.66 626 4.1 19
5 -20.42 181.96 649 4.0 11
6 -19.68 184.31 195 4.0 12
quakes <- xyplot(lat ~ long, data = quakes, aspect = "iso",
groups = cut(depth, breaks = quantile(depth, ppoints(4,
1))), auto.key = list(columns = 3, title = "Depth"),
xlab = "Longitude", ylab = "Latitude")
print(quakes)
pl <- xyplot(lat ~ long, data = quakes, aspect = "iso",
groups = cut(depth, breaks = quantile(depth, ppoints(4,
1))), auto.key = list(columns = 3, title = "Depth"),
xlab = "Longitude", ylab = "Latitude")
print(pl)
qplot(x, y, data=, color=, shape=, size=, alpha=, geom=,
method=, formula=, facets=, xlim=, ylim= xlab=, ylab=, main=,
sub=)
qplot(x, y, data=, color=, shape=, size=, alpha=, geom=,
method=, formula=, facets=, xlim=, ylim= xlab=, ylab=, main=,
sub=)
qplot(x, y, data=, color=, shape=, size=, alpha=, geom=,
method=, formula=, facets=, xlim=, ylim= xlab=, ylab=, main=,
sub=)
qplot(x, y, data=, color=, shape=, size=, alpha=, geom=,
method=, formula=, facets=, xlim=, ylim= xlab=, ylab=, main=,
sub=)
quakes$Depth <- with(quakes, cut(depth, breaks = quantile(depth,
ppoints(5, 1)), include.lowest = TRUE))
QGraph <- ggplot(quakes, aes(long, lat, colour = Depth)) +
geom_point() + coord_equal() + labs(x = "Longitude",
y = "Latitude") + ggtitle("Depth")
print(QGraph)
quakes$Depth <- with(quakes, cut(depth, breaks = quantile(depth,
ppoints(5, 1)), include.lowest = TRUE))
QGraph <- ggplot(quakes, aes(long, lat, colour = Depth)) +
geom_point() + coord_equal() + labs(x = "Longitude",
y = "Latitude") + ggtitle("Depth")
print(QGraph)
quakes$Depth <- with(quakes, cut(depth, breaks = quantile(depth,
ppoints(5, 1)), include.lowest = TRUE))
QGraph <- ggplot(quakes, aes(long, lat, colour = Depth)) +
geom_point() + coord_equal() + labs(x = "Longitude",
y = "Latitude") + ggtitle("Depth")
print(QGraph)
http://www.r-graph-gallery.com/
Samples: http://www.r-graph-gallery.com/

More Related Content

What's hot

Data preprocessing
Data preprocessingData preprocessing
Data preprocessing
ankur bhalla
 

What's hot (20)

Data visualization using R
Data visualization using RData visualization using R
Data visualization using R
 
Data preprocessing
Data preprocessingData preprocessing
Data preprocessing
 
R programming slides
R  programming slidesR  programming slides
R programming slides
 
Statistics for data science
Statistics for data science Statistics for data science
Statistics for data science
 
Data Analysis with R (combined slides)
Data Analysis with R (combined slides)Data Analysis with R (combined slides)
Data Analysis with R (combined slides)
 
Data Visualization With R
Data Visualization With RData Visualization With R
Data Visualization With R
 
Introduction to data analysis using R
Introduction to data analysis using RIntroduction to data analysis using R
Introduction to data analysis using R
 
Chart and graphs in R programming language
Chart and graphs in R programming language Chart and graphs in R programming language
Chart and graphs in R programming language
 
Statistics For Data Science | Statistics Using R Programming Language | Hypot...
Statistics For Data Science | Statistics Using R Programming Language | Hypot...Statistics For Data Science | Statistics Using R Programming Language | Hypot...
Statistics For Data Science | Statistics Using R Programming Language | Hypot...
 
R Programming Language
R Programming LanguageR Programming Language
R Programming Language
 
R programming presentation
R programming presentationR programming presentation
R programming presentation
 
Reading Data into R
Reading Data into RReading Data into R
Reading Data into R
 
Decision tree induction
Decision tree inductionDecision tree induction
Decision tree induction
 
Exploratory Data Analysis
Exploratory Data AnalysisExploratory Data Analysis
Exploratory Data Analysis
 
Data preprocessing
Data preprocessingData preprocessing
Data preprocessing
 
Data preprocessing PPT
Data preprocessing PPTData preprocessing PPT
Data preprocessing PPT
 
Unit 1 - R Programming (Part 2).pptx
Unit 1 - R Programming (Part 2).pptxUnit 1 - R Programming (Part 2).pptx
Unit 1 - R Programming (Part 2).pptx
 
Introduction to R
Introduction to RIntroduction to R
Introduction to R
 
Introduction to R Programming
Introduction to R ProgrammingIntroduction to R Programming
Introduction to R Programming
 
Data Reduction
Data ReductionData Reduction
Data Reduction
 

Similar to 8. R Graphics with R

Seminar PSU 09.04.2013 - 10.04.2013 MiFIT, Arbuzov Vyacheslav
Seminar PSU 09.04.2013 - 10.04.2013 MiFIT, Arbuzov VyacheslavSeminar PSU 09.04.2013 - 10.04.2013 MiFIT, Arbuzov Vyacheslav
Seminar PSU 09.04.2013 - 10.04.2013 MiFIT, Arbuzov Vyacheslav
Vyacheslav Arbuzov
 

Similar to 8. R Graphics with R (20)

R Programming Reference Card
R Programming Reference CardR Programming Reference Card
R Programming Reference Card
 
Short Reference Card for R users.
Short Reference Card for R users.Short Reference Card for R users.
Short Reference Card for R users.
 
Reference card for R
Reference card for RReference card for R
Reference card for R
 
statistical computation using R- an intro..
statistical computation using R- an intro..statistical computation using R- an intro..
statistical computation using R- an intro..
 
20170509 rand db_lesugent
20170509 rand db_lesugent20170509 rand db_lesugent
20170509 rand db_lesugent
 
R command cheatsheet.pdf
R command cheatsheet.pdfR command cheatsheet.pdf
R command cheatsheet.pdf
 
@ R reference
@ R reference@ R reference
@ R reference
 
R Language Introduction
R Language IntroductionR Language Introduction
R Language Introduction
 
Frp2016 3
Frp2016 3Frp2016 3
Frp2016 3
 
R language introduction
R language introductionR language introduction
R language introduction
 
Scala. Introduction to FP. Monads
Scala. Introduction to FP. MonadsScala. Introduction to FP. Monads
Scala. Introduction to FP. Monads
 
ML-CheatSheet (1).pdf
ML-CheatSheet (1).pdfML-CheatSheet (1).pdf
ML-CheatSheet (1).pdf
 
Introduction to R programming
Introduction to R programmingIntroduction to R programming
Introduction to R programming
 
R Cheat Sheet for Data Analysts and Statisticians.pdf
R Cheat Sheet for Data Analysts and Statisticians.pdfR Cheat Sheet for Data Analysts and Statisticians.pdf
R Cheat Sheet for Data Analysts and Statisticians.pdf
 
R training5
R training5R training5
R training5
 
Seminar PSU 09.04.2013 - 10.04.2013 MiFIT, Arbuzov Vyacheslav
Seminar PSU 09.04.2013 - 10.04.2013 MiFIT, Arbuzov VyacheslavSeminar PSU 09.04.2013 - 10.04.2013 MiFIT, Arbuzov Vyacheslav
Seminar PSU 09.04.2013 - 10.04.2013 MiFIT, Arbuzov Vyacheslav
 
Graph convolutional networks in apache spark
Graph convolutional networks in apache sparkGraph convolutional networks in apache spark
Graph convolutional networks in apache spark
 
Twopi.1
Twopi.1Twopi.1
Twopi.1
 
R graphics
R graphicsR graphics
R graphics
 
An Intoduction to R
An Intoduction to RAn Intoduction to R
An Intoduction to R
 

More from FAO

More from FAO (20)

Nigeria
NigeriaNigeria
Nigeria
 
Niger
NigerNiger
Niger
 
Namibia
NamibiaNamibia
Namibia
 
Mozambique
MozambiqueMozambique
Mozambique
 
Zimbabwe takesure
Zimbabwe takesureZimbabwe takesure
Zimbabwe takesure
 
Zimbabwe
ZimbabweZimbabwe
Zimbabwe
 
Zambia
ZambiaZambia
Zambia
 
Togo
TogoTogo
Togo
 
Tanzania
TanzaniaTanzania
Tanzania
 
Spal presentation
Spal presentationSpal presentation
Spal presentation
 
Rwanda
RwandaRwanda
Rwanda
 
Nigeria uponi
Nigeria uponiNigeria uponi
Nigeria uponi
 
The multi-faced role of soil in the NENA regions (part 2)
The multi-faced role of soil in the NENA regions (part 2)The multi-faced role of soil in the NENA regions (part 2)
The multi-faced role of soil in the NENA regions (part 2)
 
The multi-faced role of soil in the NENA regions (part 1)
The multi-faced role of soil in the NENA regions (part 1)The multi-faced role of soil in the NENA regions (part 1)
The multi-faced role of soil in the NENA regions (part 1)
 
Agenda of the launch of the soil policy brief at the Land&Water Days
Agenda of the launch of the soil policy brief at the Land&Water DaysAgenda of the launch of the soil policy brief at the Land&Water Days
Agenda of the launch of the soil policy brief at the Land&Water Days
 
Agenda of the 5th NENA Soil Partnership meeting
Agenda of the 5th NENA Soil Partnership meetingAgenda of the 5th NENA Soil Partnership meeting
Agenda of the 5th NENA Soil Partnership meeting
 
The Voluntary Guidelines for Sustainable Soil Management
The Voluntary Guidelines for Sustainable Soil ManagementThe Voluntary Guidelines for Sustainable Soil Management
The Voluntary Guidelines for Sustainable Soil Management
 
GLOSOLAN - Mission, status and way forward
GLOSOLAN - Mission, status and way forwardGLOSOLAN - Mission, status and way forward
GLOSOLAN - Mission, status and way forward
 
Towards a Global Soil Information System (GLOSIS)
Towards a Global Soil Information System (GLOSIS)Towards a Global Soil Information System (GLOSIS)
Towards a Global Soil Information System (GLOSIS)
 
GSP developments of regional interest in 2019
GSP developments of regional interest in 2019GSP developments of regional interest in 2019
GSP developments of regional interest in 2019
 

Recently uploaded

The basics of sentences session 3pptx.pptx
The basics of sentences session 3pptx.pptxThe basics of sentences session 3pptx.pptx
The basics of sentences session 3pptx.pptx
heathfieldcps1
 

Recently uploaded (20)

Accessible Digital Futures project (20/03/2024)
Accessible Digital Futures project (20/03/2024)Accessible Digital Futures project (20/03/2024)
Accessible Digital Futures project (20/03/2024)
 
FSB Advising Checklist - Orientation 2024
FSB Advising Checklist - Orientation 2024FSB Advising Checklist - Orientation 2024
FSB Advising Checklist - Orientation 2024
 
Beyond_Borders_Understanding_Anime_and_Manga_Fandom_A_Comprehensive_Audience_...
Beyond_Borders_Understanding_Anime_and_Manga_Fandom_A_Comprehensive_Audience_...Beyond_Borders_Understanding_Anime_and_Manga_Fandom_A_Comprehensive_Audience_...
Beyond_Borders_Understanding_Anime_and_Manga_Fandom_A_Comprehensive_Audience_...
 
General Principles of Intellectual Property: Concepts of Intellectual Proper...
General Principles of Intellectual Property: Concepts of Intellectual  Proper...General Principles of Intellectual Property: Concepts of Intellectual  Proper...
General Principles of Intellectual Property: Concepts of Intellectual Proper...
 
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...
 
Single or Multiple melodic lines structure
Single or Multiple melodic lines structureSingle or Multiple melodic lines structure
Single or Multiple melodic lines structure
 
How to Create and Manage Wizard in Odoo 17
How to Create and Manage Wizard in Odoo 17How to Create and Manage Wizard in Odoo 17
How to Create and Manage Wizard in Odoo 17
 
How to Manage Global Discount in Odoo 17 POS
How to Manage Global Discount in Odoo 17 POSHow to Manage Global Discount in Odoo 17 POS
How to Manage Global Discount in Odoo 17 POS
 
COMMUNICATING NEGATIVE NEWS - APPROACHES .pptx
COMMUNICATING NEGATIVE NEWS - APPROACHES .pptxCOMMUNICATING NEGATIVE NEWS - APPROACHES .pptx
COMMUNICATING NEGATIVE NEWS - APPROACHES .pptx
 
How to Give a Domain for a Field in Odoo 17
How to Give a Domain for a Field in Odoo 17How to Give a Domain for a Field in Odoo 17
How to Give a Domain for a Field in Odoo 17
 
The basics of sentences session 3pptx.pptx
The basics of sentences session 3pptx.pptxThe basics of sentences session 3pptx.pptx
The basics of sentences session 3pptx.pptx
 
HMCS Max Bernays Pre-Deployment Brief (May 2024).pptx
HMCS Max Bernays Pre-Deployment Brief (May 2024).pptxHMCS Max Bernays Pre-Deployment Brief (May 2024).pptx
HMCS Max Bernays Pre-Deployment Brief (May 2024).pptx
 
Graduate Outcomes Presentation Slides - English
Graduate Outcomes Presentation Slides - EnglishGraduate Outcomes Presentation Slides - English
Graduate Outcomes Presentation Slides - English
 
Exploring_the_Narrative_Style_of_Amitav_Ghoshs_Gun_Island.pptx
Exploring_the_Narrative_Style_of_Amitav_Ghoshs_Gun_Island.pptxExploring_the_Narrative_Style_of_Amitav_Ghoshs_Gun_Island.pptx
Exploring_the_Narrative_Style_of_Amitav_Ghoshs_Gun_Island.pptx
 
Plant propagation: Sexual and Asexual propapagation.pptx
Plant propagation: Sexual and Asexual propapagation.pptxPlant propagation: Sexual and Asexual propapagation.pptx
Plant propagation: Sexual and Asexual propapagation.pptx
 
On_Translating_a_Tamil_Poem_by_A_K_Ramanujan.pptx
On_Translating_a_Tamil_Poem_by_A_K_Ramanujan.pptxOn_Translating_a_Tamil_Poem_by_A_K_Ramanujan.pptx
On_Translating_a_Tamil_Poem_by_A_K_Ramanujan.pptx
 
Understanding Accommodations and Modifications
Understanding  Accommodations and ModificationsUnderstanding  Accommodations and Modifications
Understanding Accommodations and Modifications
 
On National Teacher Day, meet the 2024-25 Kenan Fellows
On National Teacher Day, meet the 2024-25 Kenan FellowsOn National Teacher Day, meet the 2024-25 Kenan Fellows
On National Teacher Day, meet the 2024-25 Kenan Fellows
 
Fostering Friendships - Enhancing Social Bonds in the Classroom
Fostering Friendships - Enhancing Social Bonds  in the ClassroomFostering Friendships - Enhancing Social Bonds  in the Classroom
Fostering Friendships - Enhancing Social Bonds in the Classroom
 
Food safety_Challenges food safety laboratories_.pdf
Food safety_Challenges food safety laboratories_.pdfFood safety_Challenges food safety laboratories_.pdf
Food safety_Challenges food safety laboratories_.pdf
 

8. R Graphics with R

  • 1.
  • 2.
  • 3.
  • 4. There are other graphic engines available through various R packages. They provide alternative ways of defining graphs, contain extra functionality, or make use of different paradigms about the elements of plot building.
  • 5. The lattice package, written by Deepayan Sarkar, attempts to improve on base R graphics by providing better defaults and the ability to easily display multivariate relationships. In particular, the package supports the creation of trellis graphs - graphs that display a variable or the relationship between variables, conditioned on one or more other variables. Usage: graph_type description formula examples barchart bar chart x~A or A~x bwplot boxplot x~A or A~x cloud 3D scatterplot z~x*y|A contourplot 3D contour plot z~x*y densityplot kernal density plot ~x|A*B dotplot dotplot ~x|A histogram histogram ~x levelplot 3D level plot z~y*x parallel parallel coordinates plot data frame splom scatterplot matrix data frame stripplot strip plots A~x or x~A xyplot scatterplot y~x|A wireframe 3D wireframe graph z~y*x
  • 6. The lattice package, written by Deepayan Sarkar, attempts to improve on base R graphics by providing better defaults and the ability to easily display multivariate relationships. In particular, the package supports the creation of trellis graphs - graphs that display a variable or the relationship between variables, conditioned on one or more other variables. Usage: > data(quakes) > head(quakes) lat long depth mag stations 1 -20.42 181.62 562 4.8 41 2 -20.62 181.03 650 4.2 15 3 -26.00 184.10 42 5.4 43 4 -17.97 181.66 626 4.1 19 5 -20.42 181.96 649 4.0 11 6 -19.68 184.31 195 4.0 12
  • 7. quakes <- xyplot(lat ~ long, data = quakes, aspect = "iso", groups = cut(depth, breaks = quantile(depth, ppoints(4, 1))), auto.key = list(columns = 3, title = "Depth"), xlab = "Longitude", ylab = "Latitude") print(quakes)
  • 8. pl <- xyplot(lat ~ long, data = quakes, aspect = "iso", groups = cut(depth, breaks = quantile(depth, ppoints(4, 1))), auto.key = list(columns = 3, title = "Depth"), xlab = "Longitude", ylab = "Latitude") print(pl)
  • 9.
  • 10. qplot(x, y, data=, color=, shape=, size=, alpha=, geom=, method=, formula=, facets=, xlim=, ylim= xlab=, ylab=, main=, sub=)
  • 11. qplot(x, y, data=, color=, shape=, size=, alpha=, geom=, method=, formula=, facets=, xlim=, ylim= xlab=, ylab=, main=, sub=)
  • 12. qplot(x, y, data=, color=, shape=, size=, alpha=, geom=, method=, formula=, facets=, xlim=, ylim= xlab=, ylab=, main=, sub=)
  • 13. qplot(x, y, data=, color=, shape=, size=, alpha=, geom=, method=, formula=, facets=, xlim=, ylim= xlab=, ylab=, main=, sub=)
  • 14. quakes$Depth <- with(quakes, cut(depth, breaks = quantile(depth, ppoints(5, 1)), include.lowest = TRUE)) QGraph <- ggplot(quakes, aes(long, lat, colour = Depth)) + geom_point() + coord_equal() + labs(x = "Longitude", y = "Latitude") + ggtitle("Depth") print(QGraph)
  • 15. quakes$Depth <- with(quakes, cut(depth, breaks = quantile(depth, ppoints(5, 1)), include.lowest = TRUE)) QGraph <- ggplot(quakes, aes(long, lat, colour = Depth)) + geom_point() + coord_equal() + labs(x = "Longitude", y = "Latitude") + ggtitle("Depth") print(QGraph)
  • 16. quakes$Depth <- with(quakes, cut(depth, breaks = quantile(depth, ppoints(5, 1)), include.lowest = TRUE)) QGraph <- ggplot(quakes, aes(long, lat, colour = Depth)) + geom_point() + coord_equal() + labs(x = "Longitude", y = "Latitude") + ggtitle("Depth") print(QGraph)
  • 17.