Professional Documents
Culture Documents
Graphical Parameters R
Graphical Parameters R
Mosaic Plots
# Set a graphical parameter using par()
Correlograms
Interactive Graphs
par() # view current settings
opar <- par() # make a copy of current settings
par(col.lab="red") # red x and y labels
hist(mtcars$mpg) # create a plot with these new settings
par(opar) # restore original settings
R in Action
See the help for a specific high level plotting function (e.g. plot, hist, boxplot) to
R in Action (2nd ed) determine which graphical parameters can be set this way.
significantly expands upon this
The remainder of this section describes some of the more important graphical
material. Use promo code ria38
for a 38% discount. parameters that you can set.
option description
Lines
You can change lines using the following options. This is particularly useful for
reference lines, axes, and fit lines.
option description
lty line type. see the chart below.
Colors
Options that specify colors include the following.
option description
You can also create a vector of n contiguous colors using the functions rainbow(n),
heat.colors(n), terrain.colors(n), topo.colors(n), and cm.colors(n).
Fonts
You can easily set font size and style, but font family is a bit more complicated.
option description
font Integer specifying font to use for text.
1=plain, 2=bold, 3=italic, 4=bold italic, 5=symbol
family font family for drawing text. Standard values are "serif",
"sans", "mono", "symbol". Mapping is device dependent.
In windows, mono is mapped to "TT Courier New", serif is mapped to"TT Times New
Roman", sans is mapped to "TT Arial", mono is mapped to "TT Courier New", and
symbol is mapped to "TT Symbol" (TT=True Type). You can add your own mappings.
click to view
option description
mar numerical vector indicating margin size c(bottom, left, top, right)
in lines. default = c(5, 4, 4, 2) + 0.1
mai numerical vector indicating margin size c(bottom, left, top, right)
in inches
pin plot dimensions (width, height) in inches
Going Further
See help(par) for more information on graphical parameters. The customization of
plotting axes and text annotations are covered next section.
To Practice
Try this course on making graphs in R.