Basic skills in R: Basic graphics
Summary of options to change features of a figure
The function par() is used to inspect and specify global graphics parameters that affect all plots in an R session. These parameters can be overridden when they are specified as arguments to specific plotting functions. For example,
mfrow(r,c): number of plots per row, column (plots are filled row-wise);mfcol(r,c): number of plots per row, column (plots are filled column-wise).
Below is an overview of parameters that can be changed (globally or locally).
pch |
The plot character parameter is a character or a number, usually between 1 and 25. that informs the graphics system which symbol to use to draw the points that it plots; see the figure below |
cex = fcex.axiscex.labcex.maincex.sub |
The character expansion (scale factor f) is the desired size of text characters (including plotting characters) relative to the default text size. It can also used for axis annotation, \(x\) and \(y\) labels, main title, and sub-title, respectively. |
col = ccol.axiscol.labcol.maincol.sub |
R has 657 built-in colours. You can see all the names by typing the instruction colors() in the console. It can also used for axis annotation, \(x\) and \(y\) labels, main title, and sub-title, respectively. |
font = sfont.axisfont.labfont.mainfont.sub |
The font is an integer s which specifies which font to use for text. If possible, device drivers arrange so that 1 corresponds to plain text, 2 to bold face, 3 to italic, 4 to bold italic and 5 to a symbol font (which include Greek letters). |
lty |
The line type parameter describes the style of line drawing. It is either a number or a word from the list below.![]() |
lwd = n |
The line width parameter is just a number n specifying the width of the line. The default value is 1. Not surprisingly, larger values produce thicker lines and smaller values produce thinner lines. |
bg = c |
The background colour is set to the colour name c. |
asp = 1 |
The aspect ratio of the figure becomes 1:1. Use asp = "r" to reset the aspect ratio to the default value. |
Unlock full access

