-
Graphics Devices
-
?Devices
?device
- only one device is the 'active' device
-
screen devices
-
Unix/Linux
- x11()
-
Windows
- windows()
-
Mac
- quartz()
-
off-screen devices
-
vector
- pdf()
- svg()
- postscript()
-
bitmap
- bmp()
- jpeg()
- png()
- tiff()
-
save plot
- 1. filetype("filename", width=xx, height=xx)
- 2. plot
- 3. dev.off()
-
Plotting Systems
-
base
-
"artist's palette" model
- 1. initiate a plot
- 2. annotate the plot
-
lattice
- Deepayan Sarkar
- creates plots with a single function call
-
ggplot2
- Hadley Wickham
- the grammar of graphics(Leland Wilkinson)
-
Functions & Arguments
- help(package="graphics")
-
plot regions
- outer margin
- figure region
- plot region
-
plot variable(s)
- single variable
- two variables
- many variables
-
par()
-
read-only
- cin
- ra
- csi
- cxy
- din
- page
-
set only by par()
- ask
- fig, fin
- lheight
- mai, mar, mex, mfcol, mfrow, mfg
- new
- oma, omd, omi
- pin, plt, ps, pty
- usr
- xlog, ylog
- ylbias
-
can also be set by high-level plot functions
- ?par
-
parameters' values
- par()$parameter
- par("parameter")
-
basic graphic commands
-
high-level
- plot()
-
barplot()
- Dot Plots: A Useful Alternative to Bar Charts
- boxplot()
- hist()
- pie()
- etc.
-
low-level
- points()
- abline()
- lines()
- axis()
- text()
- mtext()
- etc.
-
interactive
- locator()
- identify()
- getGraphicsEvent()
-
Mathematical Annotation
- ?plotmath
- demo(plotmath)
- Mathematical Annotation in R
-
multiple plots
-
plot region
- low-level commands
- high-level commands
-
plot regions
-
equal size
- par: mfrow, mfcol
-
unequal size
- par: fig, fin
split.screen()
layout()
-
packages
- CRAN packages:
- Task View: Graphics
-
Colors
-
ref.
- ColorChart.pdf
- colorPaletteCheatsheet.pdf
-
colors()
- R built-in colors: 657
-
how to use?
- color name/index
- hexidecimal number
-
functions
- rgb()
- rgb2hsv()
- col2rgb()
- colorRamp()
- colorRampPalette()
- etc.
-
palettes
-
set/view palettes
- palette()
-
grDevices
- cm.colors()
- gray.colors(), grey.colors()
- heat.colors()
- rainbow()
- terrain.colors()
- topo.colors()
-
packages
- colorspace
- dichromat
- munsell
- RColorBrewer
- wesanderson
-
Ref.
- R Graphs Cookbook Second Edition by Hrishi V. Mittal
-
R Graphics Second Edition by Paul Murrell
- R code for figures
- R Graphics Cookbook by Winston Chang
- Exploratory Data Analysis with R
- New Energy Research/R-Programming
- THE R GRAPH GALLERY
-
ggplot2: elegrant graphics for data analysis by Hadley Wickham
- The Grammar of Graphics by Leland Wilkinson
- Lattice: Multivariate Data Visualization with R by Deepayan Sarkar
- Junk Charts