Professional Documents
Culture Documents
Other customisations
> plot (x = Fibonacci,
+
main = "The first 7 Fibonacci numbers",
# title
+
sub = "An elegant series",
# subtitle
+
xlab = "Position in the sequence",
# x-axis label
+
ylab = "The Fibonacci number",
# y-axis label
+
font.main = 1,
# plain text for title
+
font.sub = 2,
# boldface font
+
font.lab = 3,
# italics
+
font.axis = 4,
# bold italics
+
col.main = "red",
# title font colour
+
col.sub = "gray25",
# subtitle font colour
+
col.lab = "black",
# label font colour
+
col.axis = "springgreen4",
# axis font colour
+
cex.main = 1.2,
# title font size
+
cex.sub = 1,
# subtitle font size
+
cex.lab = 1,
# label font size
+
cex.axis = 1,
# axis font size
+
type = "b",
# plot type: "p" point, "l" line, "b" both,
+
# "o" line over the top of points,
+
# "h" histogram-like vertical bars
+
# "s" or "S" staircase,
+
# "c" connecting lines from "b" version
+
col = "blue",
# plot colour
+
pch = 19,
# plot character
+
cex = 5,
# plot 5x the usual size
+
lty = 2,
# change line type to dashed
+
lwd = 4,
# change line width to 4x usual
+
xlim = c(0, 15),
# x scale limits
+
ylim = c(0, 15),
# y scale limits
+)
Histograms
> load("aflsmall.Rdata")
> hist(afl.margins)
> hist(afl.margins, breaks = 3)
> hist(afl.margins, breaks = 0:116)
Scatterplots
A simple scatterplot:
> library(car)
# scatterplot() is contained in this library
> scatterplot(dan.grump ~ dan.sleep,
+
data = parenthood,
+
smooth = FALSE
# prevents drawing a smooth trendline
+)
You can specify which variables you want for the matrix:
Barplots
e.g. display the number of finals each team played over the time spanned by afl dataset.
> afl.freq <- tabulate(afl.finalists)
> teams <- levels(afl.finalists)