hexbin() and smoothScatter()set.seed(123)
N <- 100
x <- rnorm(N, 100, 15)
y <- 0.3*x + rnorm(N, 0, 5)
plot(x, y)
plot(x, y, main="Customized scatter plot", xlim=c(50, 150), ylim=c(10, 50),
xlab="x axis", ylab="y axis", pch=16, col="darkgray")
plot(y, main="Univeriate scatter plot", ylim=c(10, 50),
xlab="Index", ylab="y axis", pch=4, lwd=2, col="blue")
xy <- cbind(x, y)
plot(xy)
plot(y ~ x)
# not shownUseful if one variable can take on only a few values, and one plot symbol represents many observations.
z <- sample(0:5, N, replace=TRUE)
plot(z ~ x, pch=1, col="red", cex=1.5, main="Scatter plot")
plot(jitter(z) ~ x, pch=1, col="red", cex=1.5,
main="Scatter plot with jittered y-coordinate")
plot()vec <- rnorm(10)
plot(vec, type="p", xlab=NA, main="type p", cex=1.5)
plot(vec, type="l", xlab=NA, main="type l", cex=1.5)
plot(vec, type="b", xlab=NA, main="type b", cex=1.5)
plot(vec, type="o", xlab=NA, main="type o", cex=1.5)
plot(vec, type="s", xlab=NA, main="type s", cex=1.5)
plot(vec, type="h", xlab=NA, main="type h", cex=1.5)
vec <- seq(from=-2*pi, to=2*pi, length.out=50)
mat <- cbind(2*sin(vec), sin(vec-(pi/4)), 0.5*sin(vec-(pi/2)))
matplot(vec, mat, type="b", xlab=NA, ylab=NA, pch=1:3, main="Sine-curves")
plot(vec)
identify(vec)R markdown - markdown - R code - all posts