SlideShare a Scribd company logo
 Quantile-quantile plots
qqnorm(x)
qqline(x)
Quantile – Quantile-Quantile plot
qqplot(x, y)
 Barplot
barplot(table(x1, x2), legend=c(“x1.grp1",
“x1.grp2"), xlab="X2“, beside=TRUE)
Or
library(lattice)
barchart(table(x1,x2,x3))
 Boxplots and Violin Plots
boxplot(x)
 horizontal = TRUE
library(vioplot)
vioplot(x1, x2, x3)
• Side-by-side boxplots
boxplot(y~x)
Or
library(lattice)
bwplot(y~x)
 Interaction plot
 Display means by 2 variables (in a two-way analysis
of variance)
interaction.plot(x1, x2, y)
 fun (option to change default statistic which is the
mean)
 Empirical probability density plot
 Density plots are non-parametric estimates of the
empirical probability density function
 #univariate density
plot(density(x))
 One could compare groups
by looking at kernel density
plots
 3 – D plots
persp(x, y, z)
contour(x, y, z)
Image(x, y, z)
OR
library(scatterplot3d)
scatterplot3d(x, y, z)
 The values for x and y must be in ascending order
 A list of graphical parameters that define the
default behavior of all plot functions.
 Just like other R objects, par elements are similarly
modifiable, with slightly different syntax.
◦ e.g. par(“bg”=“lightcyan”)
◦ This would change the background color of all
subsequent plots to light cyan
 When par elements are modified directly (as above,
this changes all subsequent plotting behavior.
 Size of margins
◦ par(mar=c(bot, left, top, right))
 Save graphical settings
◦ par() #view currents settings
◦ opar <- par() #make a copy of current settings
◦ par(opar) #restore original settings
 Multiple plots per page
◦ par(mfrow=c(a, b)) #a rows and b columns
◦ par(mfcol=c(a,b))
 bg – plot background color
 lty – line type (e.g. dot, dash, solid)
 lwd – line width
 col – color
 cex – text size inside plot
 xlab, ylab – axes labels
 main – title
 pch – plotting symbol
 Add an arbitrary straight line:
 plot(x, y)
 abline(intercept, slope)
 Plot symbols
 plot(x, y, pch=pchval)
PCH symbols used in R
 “col=“ and “bg=” are also specified
 PCH can also be in characters such as
“A”, “a”, “%” etc.
 Titles
 title(main=“main” , sub = “sub”, xlab=“xlab”, ylab=“ylab”)
 Mathematical Symbols
 plot(x, y)
 expr = expression(paste(mathexpression)))
 title(xlab=c(expr))
 Arrows and Shapes
 arrows(x, y)
 rect(xleft, ybottom, xright, ytop)
 polygon(x, y)
 library(plotrix)
 draw.circle(x, y, r)
 Line styles, line width and colors
 plot(….)
 lines(x, y, lty=ltyval, lwd = lwdval,
col=colval)
col Default plotting color. Some functions (e.g. lines)
accept a vector of values that are recycled.
col.axis color for axis annotation
col.lab color for x and y labels
col.main color for titles
col.sub color for subtitles
fg plot foreground color (axes, boxes - also sets col= to
same)
bg plot background color
 Legend
 plot(x, y)
 legend(xval, yval, legend = c(“Grp1”, “Grp2”),
lty=1:2, col=3:4, bty=“box type”)
 Add a legend at the location at (xval, yval)
 A vector of legend labels, line types,
and colors can be specified
using legend, lty and col options.
 bty =“o” or “n”
 Adding Points or Lines to an Existing Graphic
 plot(x, y)
 points(x, y)
 lines(x, y, type=“type”)
type =
 p points
 l lines
 o overplotted points and lines
 b, c points (empty if "c") joined by lines
 s, S stair steps
 h histogram-like vertical lines
 n does not produce any points or lines
 OLS line fit to the points
 plot(x, y)
 abline(lm(y~x))
 Graph Size
 pdf(“filename.pdf”, width = Xin, height = Yin)
 Point and text size
 plot(x, y, cex = cexval)
 cex number indicating the amount by which
plotting text and symbols should be scaled relative to the
default. 1=default, 1.5 is 50% larger, 0.5 is 50% smaller,
etc.
 cex.axis magnification of axis annotation relative to cex
 cex.lab magnification of x and y labels relative to cex
 cex.main magnification of titles relative to cex
 cex.sub magnification of subtitles relative to cex
 Box around plots
 plot(x, y, bty = btyval)
 Axis labels, values, and tick marks
◦ plot(x, y, lab=c(x, y, len), #number of tick marks
las=lasval, #orientation of tick marks
tck = tckval, #length of tick marks
xaxp = c(x1, x2, n), #coordinates of the extreme tick
marks
yaxp = c(x1, x2, n),
xlab = “X axis label”, ylab=“Y axis label”)
◦ las = 0 labels are parallel to axis
◦ las=2 labels are perpendicular to axis
◦ tck = 0 suppresses the tick mark
 Axis Range and Style
◦ plot(x, y, xlim = c(minx, maxx), ylim = c (miny, maxy),
xaxs=“i”, yaxs=“i”)
 The xaxs and yaxs control whether the tick marks extend
beyond the limits of the plotted observations (default) or are
constrained to be internal (“i”)
 See also:
 axis()
 mtext()
 Omit axis
◦ plot(x, y, xaxt = “n”, yaxy=“n”)
 Fonts
 font Integer specifying font to use for text.
1=plain, 2=bold, 3=italic, 4=bold italic,
5=symbol
 font.axis font for axis annotation
 font.lab font for x and y labels
 font.main font for titles
 font.sub font for subtitles
 ps font point size (roughly 1/72 inch)
text size=ps*cex
 family font family for drawing text. Standard values
are "serif", "sans", "mono", "symbol".
 More on how to change colors
◦ You can specify colors in R by index, name,
hexadecimal, or RGB.
◦ For example col=1, col="white", and col="#FFFFFF"
are equivalent.
◦ colors() #list of color names
 The number of plots on a page, and their placement on the page,
can be controlled using par() or layout().
 The number of figure regions can be controlled using mfrow and
mfcol.
e.g. par(mfrow=c(3,2)) # Creates 6 figures arranged in
3 rows and 2 columns
 layout() allows the creation of multiple figure regions of unequal
sizes.
e.g. layout(matrix(c(1,2)), heights=c(2,1))
 Many statistical functions (regression, cluster
analysis) create special objects. These arguments
will automatically format graphical output in a
specific way.
 e.g. Produce diagnostic plots from a linear model
analysis (see R code)
# Reg = lm()
# plot(Reg)
 hclust()
 agnes() # hierarchical cluster analysis
 Specify destination of graphics output or simply right
click and copy
 Could be files
◦ Not Scalable
 JPG # not recommended, introduces blurry artifacts
around the lines
 BMP
 PNG
◦ Scalable:
 Postscript # preferred in LaTex
 Pdf # great for posters
 pdf(“file.pdf”)
 plot(….)
 dev.off()
 jpeg(“file.jpeg”)
 plot(…)
 dev.off()
 win.metafile(file.wmf)
 plot(…)
 dev.off()
 Similar code for BMP, TIFF, PNG, POSTSCRIPT
 PNG is usually recommended
 The dev.off() function is used to close the graphical device

More Related Content

What's hot

Introduction to r
Introduction to rIntroduction to r
Introduction to r
Golden Julie Jesus
 
4.2 graph linear equations day 1
4.2 graph linear equations   day 14.2 graph linear equations   day 1
4.2 graph linear equations day 1bweldon
 
Presentation: Plotting Systems in R
Presentation: Plotting Systems in RPresentation: Plotting Systems in R
Presentation: Plotting Systems in R
Ilya Zhbannikov
 
d3 is cool
d3 is coold3 is cool
d3 is cool
Mark Brown
 
Representacion funciones sage cell
Representacion funciones sage cellRepresentacion funciones sage cell
Representacion funciones sage cell
Marcos Otero
 
The Essence of the Iterator Pattern
The Essence of the Iterator PatternThe Essence of the Iterator Pattern
The Essence of the Iterator Pattern
Eric Torreborre
 
Matlab plotting
Matlab plottingMatlab plotting
Matlab plotting
shahid sultan
 
Py lecture5 python plots
Py lecture5 python plotsPy lecture5 python plots
Py lecture5 python plots
Yoshiki Satotani
 
Plot3D Package and Example in R.-Data visualizat,on
Plot3D Package and Example in R.-Data visualizat,onPlot3D Package and Example in R.-Data visualizat,on
Plot3D Package and Example in R.-Data visualizat,on
Dr. Volkan OBAN
 
Python - Numpy/Pandas/Matplot Machine Learning Libraries
Python - Numpy/Pandas/Matplot Machine Learning LibrariesPython - Numpy/Pandas/Matplot Machine Learning Libraries
Python - Numpy/Pandas/Matplot Machine Learning Libraries
Andrew Ferlitsch
 
(2015 06-16) Three Approaches to Monads
(2015 06-16) Three Approaches to Monads(2015 06-16) Three Approaches to Monads
(2015 06-16) Three Approaches to Monads
Lawrence Evans
 
The Essence of the Iterator Pattern (pdf)
The Essence of the Iterator Pattern (pdf)The Essence of the Iterator Pattern (pdf)
The Essence of the Iterator Pattern (pdf)
Eric Torreborre
 
Sequence and Traverse - Part 1
Sequence and Traverse - Part 1Sequence and Traverse - Part 1
Sequence and Traverse - Part 1
Philip Schwarz
 
Matlab ploting
Matlab plotingMatlab ploting
Matlab ploting
Ameen San
 
Symmetry in the interrelation of flatMap/foldMap/traverse and flatten/fold/se...
Symmetry in the interrelation of flatMap/foldMap/traverse and flatten/fold/se...Symmetry in the interrelation of flatMap/foldMap/traverse and flatten/fold/se...
Symmetry in the interrelation of flatMap/foldMap/traverse and flatten/fold/se...
Philip Schwarz
 
R gráfico
R gráficoR gráfico
R gráfico
stryper1968
 
Scala collection methods flatMap and flatten are more powerful than monadic f...
Scala collection methods flatMap and flatten are more powerful than monadic f...Scala collection methods flatMap and flatten are more powerful than monadic f...
Scala collection methods flatMap and flatten are more powerful than monadic f...
Philip Schwarz
 
Lecture 02 visualization and programming
Lecture 02   visualization and programmingLecture 02   visualization and programming
Lecture 02 visualization and programming
Smee Kaem Chann
 

What's hot (20)

Introduction to r
Introduction to rIntroduction to r
Introduction to r
 
4.2 graph linear equations day 1
4.2 graph linear equations   day 14.2 graph linear equations   day 1
4.2 graph linear equations day 1
 
Presentation: Plotting Systems in R
Presentation: Plotting Systems in RPresentation: Plotting Systems in R
Presentation: Plotting Systems in R
 
d3 is cool
d3 is coold3 is cool
d3 is cool
 
Representacion funciones sage cell
Representacion funciones sage cellRepresentacion funciones sage cell
Representacion funciones sage cell
 
The Essence of the Iterator Pattern
The Essence of the Iterator PatternThe Essence of the Iterator Pattern
The Essence of the Iterator Pattern
 
Matlab plotting
Matlab plottingMatlab plotting
Matlab plotting
 
Py lecture5 python plots
Py lecture5 python plotsPy lecture5 python plots
Py lecture5 python plots
 
Plot3D Package and Example in R.-Data visualizat,on
Plot3D Package and Example in R.-Data visualizat,onPlot3D Package and Example in R.-Data visualizat,on
Plot3D Package and Example in R.-Data visualizat,on
 
parent functons
parent functonsparent functons
parent functons
 
Python - Numpy/Pandas/Matplot Machine Learning Libraries
Python - Numpy/Pandas/Matplot Machine Learning LibrariesPython - Numpy/Pandas/Matplot Machine Learning Libraries
Python - Numpy/Pandas/Matplot Machine Learning Libraries
 
(2015 06-16) Three Approaches to Monads
(2015 06-16) Three Approaches to Monads(2015 06-16) Three Approaches to Monads
(2015 06-16) Three Approaches to Monads
 
The Essence of the Iterator Pattern (pdf)
The Essence of the Iterator Pattern (pdf)The Essence of the Iterator Pattern (pdf)
The Essence of the Iterator Pattern (pdf)
 
Sequence and Traverse - Part 1
Sequence and Traverse - Part 1Sequence and Traverse - Part 1
Sequence and Traverse - Part 1
 
Matlab ploting
Matlab plotingMatlab ploting
Matlab ploting
 
Symmetry in the interrelation of flatMap/foldMap/traverse and flatten/fold/se...
Symmetry in the interrelation of flatMap/foldMap/traverse and flatten/fold/se...Symmetry in the interrelation of flatMap/foldMap/traverse and flatten/fold/se...
Symmetry in the interrelation of flatMap/foldMap/traverse and flatten/fold/se...
 
R gráfico
R gráficoR gráfico
R gráfico
 
Scala collection methods flatMap and flatten are more powerful than monadic f...
Scala collection methods flatMap and flatten are more powerful than monadic f...Scala collection methods flatMap and flatten are more powerful than monadic f...
Scala collection methods flatMap and flatten are more powerful than monadic f...
 
Lecture 02 visualization and programming
Lecture 02   visualization and programmingLecture 02   visualization and programming
Lecture 02 visualization and programming
 
11 library
11 library11 library
11 library
 

Similar to R graphics

R training5
R training5R training5
R training5
Hellen Gakuruh
 
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
CHANDAN KUMAR
 
Short Reference Card for R users.
Short Reference Card for R users.Short Reference Card for R users.
Short Reference Card for R users.
Dr. Volkan OBAN
 
Reference card for R
Reference card for RReference card for R
Reference card for R
Dr. Volkan OBAN
 
R Programming Reference Card
R Programming Reference CardR Programming Reference Card
R Programming Reference Card
Maurice Dawson
 
@ R reference
@ R reference@ R reference
@ R reference
vickyrolando
 
R command cheatsheet.pdf
R command cheatsheet.pdfR command cheatsheet.pdf
R command cheatsheet.pdf
Ngcnh947953
 
20170509 rand db_lesugent
20170509 rand db_lesugent20170509 rand db_lesugent
20170509 rand db_lesugent
Prof. Wim Van Criekinge
 
Exploratory data analysis using r
Exploratory data analysis using rExploratory data analysis using r
Exploratory data analysis using r
Tahera Shaikh
 
R language introduction
R language introductionR language introduction
R language introduction
Shashwat Shriparv
 
statistical computation using R- an intro..
statistical computation using R- an intro..statistical computation using R- an intro..
statistical computation using R- an intro..
Kamarudheen KV
 
How big-is-your-graph
How big-is-your-graphHow big-is-your-graph
How big-is-your-graph
Dieudonne Nahigombeye
 
lect.no.3.pptx
lect.no.3.pptxlect.no.3.pptx
lect.no.3.pptx
ahmed343312
 
Matlab plotting
Matlab plottingMatlab plotting
Matlab plotting
pink1710
 
Data transformation-cheatsheet
Data transformation-cheatsheetData transformation-cheatsheet
Data transformation-cheatsheet
Dieudonne Nahigombeye
 
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 VyacheslavVyacheslav Arbuzov
 
Rcommands-for those who interested in R.
Rcommands-for those who interested in R.Rcommands-for those who interested in R.
Rcommands-for those who interested in R.
Dr. Volkan OBAN
 

Similar to R graphics (20)

R training5
R training5R training5
R training5
 
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
 
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
 
R Programming Reference Card
R Programming Reference CardR Programming Reference Card
R Programming Reference Card
 
ML-CheatSheet (1).pdf
ML-CheatSheet (1).pdfML-CheatSheet (1).pdf
ML-CheatSheet (1).pdf
 
@ R reference
@ R reference@ R reference
@ R reference
 
R command cheatsheet.pdf
R command cheatsheet.pdfR command cheatsheet.pdf
R command cheatsheet.pdf
 
20170509 rand db_lesugent
20170509 rand db_lesugent20170509 rand db_lesugent
20170509 rand db_lesugent
 
Exploratory data analysis using r
Exploratory data analysis using rExploratory data analysis using r
Exploratory data analysis using r
 
Lesson 3
Lesson 3Lesson 3
Lesson 3
 
R language introduction
R language introductionR language introduction
R language introduction
 
statistical computation using R- an intro..
statistical computation using R- an intro..statistical computation using R- an intro..
statistical computation using R- an intro..
 
How big-is-your-graph
How big-is-your-graphHow big-is-your-graph
How big-is-your-graph
 
lect.no.3.pptx
lect.no.3.pptxlect.no.3.pptx
lect.no.3.pptx
 
Matlab plotting
Matlab plottingMatlab plotting
Matlab plotting
 
Data transformation-cheatsheet
Data transformation-cheatsheetData transformation-cheatsheet
Data transformation-cheatsheet
 
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
 
purrr.pdf
purrr.pdfpurrr.pdf
purrr.pdf
 
Rcommands-for those who interested in R.
Rcommands-for those who interested in R.Rcommands-for those who interested in R.
Rcommands-for those who interested in R.
 

More from DHIVYADEVAKI

Computer Networks - DNS
Computer Networks - DNSComputer Networks - DNS
Computer Networks - DNS
DHIVYADEVAKI
 
Error detection methods-computer networks
Error detection methods-computer networksError detection methods-computer networks
Error detection methods-computer networks
DHIVYADEVAKI
 
Introduction basic schema and SQL QUERIES
Introduction basic schema and SQL QUERIESIntroduction basic schema and SQL QUERIES
Introduction basic schema and SQL QUERIES
DHIVYADEVAKI
 
Image compression in digital image processing
Image compression in digital image processingImage compression in digital image processing
Image compression in digital image processing
DHIVYADEVAKI
 
Image segmentation in Digital Image Processing
Image segmentation in Digital Image ProcessingImage segmentation in Digital Image Processing
Image segmentation in Digital Image Processing
DHIVYADEVAKI
 
Data preprocessing in Data Mining
Data preprocessing in Data MiningData preprocessing in Data Mining
Data preprocessing in Data Mining
DHIVYADEVAKI
 
Apriori algorithm
Apriori algorithm Apriori algorithm
Apriori algorithm
DHIVYADEVAKI
 
Types of Load distributing algorithm in Distributed System
Types of Load distributing algorithm in Distributed SystemTypes of Load distributing algorithm in Distributed System
Types of Load distributing algorithm in Distributed System
DHIVYADEVAKI
 
Deadlock Detection in Distributed Systems
Deadlock Detection in Distributed SystemsDeadlock Detection in Distributed Systems
Deadlock Detection in Distributed Systems
DHIVYADEVAKI
 

More from DHIVYADEVAKI (9)

Computer Networks - DNS
Computer Networks - DNSComputer Networks - DNS
Computer Networks - DNS
 
Error detection methods-computer networks
Error detection methods-computer networksError detection methods-computer networks
Error detection methods-computer networks
 
Introduction basic schema and SQL QUERIES
Introduction basic schema and SQL QUERIESIntroduction basic schema and SQL QUERIES
Introduction basic schema and SQL QUERIES
 
Image compression in digital image processing
Image compression in digital image processingImage compression in digital image processing
Image compression in digital image processing
 
Image segmentation in Digital Image Processing
Image segmentation in Digital Image ProcessingImage segmentation in Digital Image Processing
Image segmentation in Digital Image Processing
 
Data preprocessing in Data Mining
Data preprocessing in Data MiningData preprocessing in Data Mining
Data preprocessing in Data Mining
 
Apriori algorithm
Apriori algorithm Apriori algorithm
Apriori algorithm
 
Types of Load distributing algorithm in Distributed System
Types of Load distributing algorithm in Distributed SystemTypes of Load distributing algorithm in Distributed System
Types of Load distributing algorithm in Distributed System
 
Deadlock Detection in Distributed Systems
Deadlock Detection in Distributed SystemsDeadlock Detection in Distributed Systems
Deadlock Detection in Distributed Systems
 

Recently uploaded

special B.ed 2nd year old paper_20240531.pdf
special B.ed 2nd year old paper_20240531.pdfspecial B.ed 2nd year old paper_20240531.pdf
special B.ed 2nd year old paper_20240531.pdf
Special education needs
 
Sha'Carri Richardson Presentation 202345
Sha'Carri Richardson Presentation 202345Sha'Carri Richardson Presentation 202345
Sha'Carri Richardson Presentation 202345
beazzy04
 
Digital Tools and AI for Teaching Learning and Research
Digital Tools and AI for Teaching Learning and ResearchDigital Tools and AI for Teaching Learning and Research
Digital Tools and AI for Teaching Learning and Research
Vikramjit Singh
 
Additional Benefits for Employee Website.pdf
Additional Benefits for Employee Website.pdfAdditional Benefits for Employee Website.pdf
Additional Benefits for Employee Website.pdf
joachimlavalley1
 
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
siemaillard
 
Supporting (UKRI) OA monographs at Salford.pptx
Supporting (UKRI) OA monographs at Salford.pptxSupporting (UKRI) OA monographs at Salford.pptx
Supporting (UKRI) OA monographs at Salford.pptx
Jisc
 
Basic phrases for greeting and assisting costumers
Basic phrases for greeting and assisting costumersBasic phrases for greeting and assisting costumers
Basic phrases for greeting and assisting costumers
PedroFerreira53928
 
Overview on Edible Vaccine: Pros & Cons with Mechanism
Overview on Edible Vaccine: Pros & Cons with MechanismOverview on Edible Vaccine: Pros & Cons with Mechanism
Overview on Edible Vaccine: Pros & Cons with Mechanism
DeeptiGupta154
 
Welcome to TechSoup New Member Orientation and Q&A (May 2024).pdf
Welcome to TechSoup   New Member Orientation and Q&A (May 2024).pdfWelcome to TechSoup   New Member Orientation and Q&A (May 2024).pdf
Welcome to TechSoup New Member Orientation and Q&A (May 2024).pdf
TechSoup
 
CLASS 11 CBSE B.St Project AIDS TO TRADE - INSURANCE
CLASS 11 CBSE B.St Project AIDS TO TRADE - INSURANCECLASS 11 CBSE B.St Project AIDS TO TRADE - INSURANCE
CLASS 11 CBSE B.St Project AIDS TO TRADE - INSURANCE
BhavyaRajput3
 
Operation Blue Star - Saka Neela Tara
Operation Blue Star   -  Saka Neela TaraOperation Blue Star   -  Saka Neela Tara
Operation Blue Star - Saka Neela Tara
Balvir Singh
 
The Challenger.pdf DNHS Official Publication
The Challenger.pdf DNHS Official PublicationThe Challenger.pdf DNHS Official Publication
The Challenger.pdf DNHS Official Publication
Delapenabediema
 
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
siemaillard
 
Unit 2- Research Aptitude (UGC NET Paper I).pdf
Unit 2- Research Aptitude (UGC NET Paper I).pdfUnit 2- Research Aptitude (UGC NET Paper I).pdf
Unit 2- Research Aptitude (UGC NET Paper I).pdf
Thiyagu K
 
ESC Beyond Borders _From EU to You_ InfoPack general.pdf
ESC Beyond Borders _From EU to You_ InfoPack general.pdfESC Beyond Borders _From EU to You_ InfoPack general.pdf
ESC Beyond Borders _From EU to You_ InfoPack general.pdf
Fundacja Rozwoju Społeczeństwa Przedsiębiorczego
 
TESDA TM1 REVIEWER FOR NATIONAL ASSESSMENT WRITTEN AND ORAL QUESTIONS WITH A...
TESDA TM1 REVIEWER  FOR NATIONAL ASSESSMENT WRITTEN AND ORAL QUESTIONS WITH A...TESDA TM1 REVIEWER  FOR NATIONAL ASSESSMENT WRITTEN AND ORAL QUESTIONS WITH A...
TESDA TM1 REVIEWER FOR NATIONAL ASSESSMENT WRITTEN AND ORAL QUESTIONS WITH A...
EugeneSaldivar
 
MARUTI SUZUKI- A Successful Joint Venture in India.pptx
MARUTI SUZUKI- A Successful Joint Venture in India.pptxMARUTI SUZUKI- A Successful Joint Venture in India.pptx
MARUTI SUZUKI- A Successful Joint Venture in India.pptx
bennyroshan06
 
PART A. Introduction to Costumer Service
PART A. Introduction to Costumer ServicePART A. Introduction to Costumer Service
PART A. Introduction to Costumer Service
PedroFerreira53928
 
Introduction to Quality Improvement Essentials
Introduction to Quality Improvement EssentialsIntroduction to Quality Improvement Essentials
Introduction to Quality Improvement Essentials
Excellence Foundation for South Sudan
 
Chapter 3 - Islamic Banking Products and Services.pptx
Chapter 3 - Islamic Banking Products and Services.pptxChapter 3 - Islamic Banking Products and Services.pptx
Chapter 3 - Islamic Banking Products and Services.pptx
Mohd Adib Abd Muin, Senior Lecturer at Universiti Utara Malaysia
 

Recently uploaded (20)

special B.ed 2nd year old paper_20240531.pdf
special B.ed 2nd year old paper_20240531.pdfspecial B.ed 2nd year old paper_20240531.pdf
special B.ed 2nd year old paper_20240531.pdf
 
Sha'Carri Richardson Presentation 202345
Sha'Carri Richardson Presentation 202345Sha'Carri Richardson Presentation 202345
Sha'Carri Richardson Presentation 202345
 
Digital Tools and AI for Teaching Learning and Research
Digital Tools and AI for Teaching Learning and ResearchDigital Tools and AI for Teaching Learning and Research
Digital Tools and AI for Teaching Learning and Research
 
Additional Benefits for Employee Website.pdf
Additional Benefits for Employee Website.pdfAdditional Benefits for Employee Website.pdf
Additional Benefits for Employee Website.pdf
 
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
 
Supporting (UKRI) OA monographs at Salford.pptx
Supporting (UKRI) OA monographs at Salford.pptxSupporting (UKRI) OA monographs at Salford.pptx
Supporting (UKRI) OA monographs at Salford.pptx
 
Basic phrases for greeting and assisting costumers
Basic phrases for greeting and assisting costumersBasic phrases for greeting and assisting costumers
Basic phrases for greeting and assisting costumers
 
Overview on Edible Vaccine: Pros & Cons with Mechanism
Overview on Edible Vaccine: Pros & Cons with MechanismOverview on Edible Vaccine: Pros & Cons with Mechanism
Overview on Edible Vaccine: Pros & Cons with Mechanism
 
Welcome to TechSoup New Member Orientation and Q&A (May 2024).pdf
Welcome to TechSoup   New Member Orientation and Q&A (May 2024).pdfWelcome to TechSoup   New Member Orientation and Q&A (May 2024).pdf
Welcome to TechSoup New Member Orientation and Q&A (May 2024).pdf
 
CLASS 11 CBSE B.St Project AIDS TO TRADE - INSURANCE
CLASS 11 CBSE B.St Project AIDS TO TRADE - INSURANCECLASS 11 CBSE B.St Project AIDS TO TRADE - INSURANCE
CLASS 11 CBSE B.St Project AIDS TO TRADE - INSURANCE
 
Operation Blue Star - Saka Neela Tara
Operation Blue Star   -  Saka Neela TaraOperation Blue Star   -  Saka Neela Tara
Operation Blue Star - Saka Neela Tara
 
The Challenger.pdf DNHS Official Publication
The Challenger.pdf DNHS Official PublicationThe Challenger.pdf DNHS Official Publication
The Challenger.pdf DNHS Official Publication
 
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
 
Unit 2- Research Aptitude (UGC NET Paper I).pdf
Unit 2- Research Aptitude (UGC NET Paper I).pdfUnit 2- Research Aptitude (UGC NET Paper I).pdf
Unit 2- Research Aptitude (UGC NET Paper I).pdf
 
ESC Beyond Borders _From EU to You_ InfoPack general.pdf
ESC Beyond Borders _From EU to You_ InfoPack general.pdfESC Beyond Borders _From EU to You_ InfoPack general.pdf
ESC Beyond Borders _From EU to You_ InfoPack general.pdf
 
TESDA TM1 REVIEWER FOR NATIONAL ASSESSMENT WRITTEN AND ORAL QUESTIONS WITH A...
TESDA TM1 REVIEWER  FOR NATIONAL ASSESSMENT WRITTEN AND ORAL QUESTIONS WITH A...TESDA TM1 REVIEWER  FOR NATIONAL ASSESSMENT WRITTEN AND ORAL QUESTIONS WITH A...
TESDA TM1 REVIEWER FOR NATIONAL ASSESSMENT WRITTEN AND ORAL QUESTIONS WITH A...
 
MARUTI SUZUKI- A Successful Joint Venture in India.pptx
MARUTI SUZUKI- A Successful Joint Venture in India.pptxMARUTI SUZUKI- A Successful Joint Venture in India.pptx
MARUTI SUZUKI- A Successful Joint Venture in India.pptx
 
PART A. Introduction to Costumer Service
PART A. Introduction to Costumer ServicePART A. Introduction to Costumer Service
PART A. Introduction to Costumer Service
 
Introduction to Quality Improvement Essentials
Introduction to Quality Improvement EssentialsIntroduction to Quality Improvement Essentials
Introduction to Quality Improvement Essentials
 
Chapter 3 - Islamic Banking Products and Services.pptx
Chapter 3 - Islamic Banking Products and Services.pptxChapter 3 - Islamic Banking Products and Services.pptx
Chapter 3 - Islamic Banking Products and Services.pptx
 

R graphics

  • 1.
  • 2.  Quantile-quantile plots qqnorm(x) qqline(x) Quantile – Quantile-Quantile plot qqplot(x, y)
  • 3.  Barplot barplot(table(x1, x2), legend=c(“x1.grp1", “x1.grp2"), xlab="X2“, beside=TRUE) Or library(lattice) barchart(table(x1,x2,x3))
  • 4.  Boxplots and Violin Plots boxplot(x)  horizontal = TRUE library(vioplot) vioplot(x1, x2, x3) • Side-by-side boxplots boxplot(y~x) Or library(lattice) bwplot(y~x)
  • 5.  Interaction plot  Display means by 2 variables (in a two-way analysis of variance) interaction.plot(x1, x2, y)  fun (option to change default statistic which is the mean)
  • 6.  Empirical probability density plot  Density plots are non-parametric estimates of the empirical probability density function  #univariate density plot(density(x))  One could compare groups by looking at kernel density plots
  • 7.  3 – D plots persp(x, y, z) contour(x, y, z) Image(x, y, z) OR library(scatterplot3d) scatterplot3d(x, y, z)  The values for x and y must be in ascending order
  • 8.  A list of graphical parameters that define the default behavior of all plot functions.  Just like other R objects, par elements are similarly modifiable, with slightly different syntax. ◦ e.g. par(“bg”=“lightcyan”) ◦ This would change the background color of all subsequent plots to light cyan  When par elements are modified directly (as above, this changes all subsequent plotting behavior.
  • 9.  Size of margins ◦ par(mar=c(bot, left, top, right))  Save graphical settings ◦ par() #view currents settings ◦ opar <- par() #make a copy of current settings ◦ par(opar) #restore original settings  Multiple plots per page ◦ par(mfrow=c(a, b)) #a rows and b columns ◦ par(mfcol=c(a,b))
  • 10.  bg – plot background color  lty – line type (e.g. dot, dash, solid)  lwd – line width  col – color  cex – text size inside plot  xlab, ylab – axes labels  main – title  pch – plotting symbol
  • 11.  Add an arbitrary straight line:  plot(x, y)  abline(intercept, slope)  Plot symbols  plot(x, y, pch=pchval) PCH symbols used in R  “col=“ and “bg=” are also specified  PCH can also be in characters such as “A”, “a”, “%” etc.
  • 12.  Titles  title(main=“main” , sub = “sub”, xlab=“xlab”, ylab=“ylab”)  Mathematical Symbols  plot(x, y)  expr = expression(paste(mathexpression)))  title(xlab=c(expr))  Arrows and Shapes  arrows(x, y)  rect(xleft, ybottom, xright, ytop)  polygon(x, y)  library(plotrix)  draw.circle(x, y, r)
  • 13.
  • 14.  Line styles, line width and colors  plot(….)  lines(x, y, lty=ltyval, lwd = lwdval, col=colval) col Default plotting color. Some functions (e.g. lines) accept a vector of values that are recycled. col.axis color for axis annotation col.lab color for x and y labels col.main color for titles col.sub color for subtitles fg plot foreground color (axes, boxes - also sets col= to same) bg plot background color
  • 15.  Legend  plot(x, y)  legend(xval, yval, legend = c(“Grp1”, “Grp2”), lty=1:2, col=3:4, bty=“box type”)  Add a legend at the location at (xval, yval)  A vector of legend labels, line types, and colors can be specified using legend, lty and col options.  bty =“o” or “n”
  • 16.  Adding Points or Lines to an Existing Graphic  plot(x, y)  points(x, y)  lines(x, y, type=“type”) type =  p points  l lines  o overplotted points and lines  b, c points (empty if "c") joined by lines  s, S stair steps  h histogram-like vertical lines  n does not produce any points or lines  OLS line fit to the points  plot(x, y)  abline(lm(y~x))
  • 17.  Graph Size  pdf(“filename.pdf”, width = Xin, height = Yin)  Point and text size  plot(x, y, cex = cexval)  cex number indicating the amount by which plotting text and symbols should be scaled relative to the default. 1=default, 1.5 is 50% larger, 0.5 is 50% smaller, etc.  cex.axis magnification of axis annotation relative to cex  cex.lab magnification of x and y labels relative to cex  cex.main magnification of titles relative to cex  cex.sub magnification of subtitles relative to cex  Box around plots  plot(x, y, bty = btyval)
  • 18.  Axis labels, values, and tick marks ◦ plot(x, y, lab=c(x, y, len), #number of tick marks las=lasval, #orientation of tick marks tck = tckval, #length of tick marks xaxp = c(x1, x2, n), #coordinates of the extreme tick marks yaxp = c(x1, x2, n), xlab = “X axis label”, ylab=“Y axis label”) ◦ las = 0 labels are parallel to axis ◦ las=2 labels are perpendicular to axis ◦ tck = 0 suppresses the tick mark
  • 19.  Axis Range and Style ◦ plot(x, y, xlim = c(minx, maxx), ylim = c (miny, maxy), xaxs=“i”, yaxs=“i”)  The xaxs and yaxs control whether the tick marks extend beyond the limits of the plotted observations (default) or are constrained to be internal (“i”)  See also:  axis()  mtext()  Omit axis ◦ plot(x, y, xaxt = “n”, yaxy=“n”)
  • 20.  Fonts  font Integer specifying font to use for text. 1=plain, 2=bold, 3=italic, 4=bold italic, 5=symbol  font.axis font for axis annotation  font.lab font for x and y labels  font.main font for titles  font.sub font for subtitles  ps font point size (roughly 1/72 inch) text size=ps*cex  family font family for drawing text. Standard values are "serif", "sans", "mono", "symbol".
  • 21.  More on how to change colors ◦ You can specify colors in R by index, name, hexadecimal, or RGB. ◦ For example col=1, col="white", and col="#FFFFFF" are equivalent. ◦ colors() #list of color names
  • 22.  The number of plots on a page, and their placement on the page, can be controlled using par() or layout().  The number of figure regions can be controlled using mfrow and mfcol. e.g. par(mfrow=c(3,2)) # Creates 6 figures arranged in 3 rows and 2 columns  layout() allows the creation of multiple figure regions of unequal sizes. e.g. layout(matrix(c(1,2)), heights=c(2,1))
  • 23.  Many statistical functions (regression, cluster analysis) create special objects. These arguments will automatically format graphical output in a specific way.  e.g. Produce diagnostic plots from a linear model analysis (see R code) # Reg = lm() # plot(Reg)  hclust()  agnes() # hierarchical cluster analysis
  • 24.  Specify destination of graphics output or simply right click and copy  Could be files ◦ Not Scalable  JPG # not recommended, introduces blurry artifacts around the lines  BMP  PNG ◦ Scalable:  Postscript # preferred in LaTex  Pdf # great for posters
  • 25.  pdf(“file.pdf”)  plot(….)  dev.off()  jpeg(“file.jpeg”)  plot(…)  dev.off()  win.metafile(file.wmf)  plot(…)  dev.off()  Similar code for BMP, TIFF, PNG, POSTSCRIPT  PNG is usually recommended  The dev.off() function is used to close the graphical device