# Graphical procedures

``````set.seed(871015)
x = rnorm(100)``````

# `par()`reference

``````par()  # graphics parameters
par(c("col", "lty"))
par(col=4, lty=2)``````

# Reset `par()`howto

Just call `dev.off()`

# `plot()`reference

``````plot(x, y)
plot(xy)
plot(x)
plot(f)
plot(f, y)
plot(df)
plot(~ expr)
plot(y ~ expr)
qqnorm(x)
qqline(x)
qqplot(x, y)
hist(x)
hist(x, nclass=n)
hist(x, breaks=b, …)
dotchart(x, …)
image(x, y, z, …)
contour(x, y, z, …)
persp(x, y, z, …)``````

# `hist()`reference

Default
``hist(x)``

Density
``hist(x, freq=FALSE)``

# `abline()`reference

``````abline(a, b)
abline(h=y)
abline(v=x)
abline(lm.obj)``````

# `curve()`reference

``````# 'x' is a special variable, which acts as a lambda placeholder
curve(dnorm(x))``````

``curve(dnorm(x), from = -3, to = 3)``

``````hist(x, freq=FALSE)

# Use `layout()` to organize plots howto

• This is like the `grid-template-areas` property of CSS.
• Each number stands for the next N th plot.
• Each number in the argument matrix corresponds to the visual position of the plots.
``````layout(matrix(c(1, 1, 1,
2, 3, 4,
2, 3, 4), nr=3, byrow=T))
hist(rnorm(25), col="VioletRed")
hist(rnorm(25), col="VioletRed")
hist(rnorm(25), col="VioletRed")
hist(rnorm(25), col="VioletRed")``````

# others

``````points(x, y)
lines(x, y)
text(x, y, labels, …)
polygon(x, y, …)
legend(x, y, legend, …)
title(main, sub)
axis(side, …)``````