# R plot 画图

x和yget data

par(mfrow=c(2, 2), mar=c(1, 1, 2, 1))
par(cex=0.7)
x <- 1:10
y <- matrix(sort(rnorm(30)), ncol=3)

================================================

plot(x, y[,1], ylim=range(y), ann=FALSE, axe=FALSE, type="l", col="red")

#ylim指定纵坐标的range
axis(1, at = 1:max(x), labels = letters[1:max(x)])
axis(2)
points(x, y[,1])
lines(x, y[,2], col="green")
points(x, y[,2], pch=2)
lines(x, y[,3], col="blue")
points(x, y[,3], pch=3)

box(lty='1373',col='red')

=================================================

plot(x, y[,1], ylim=range(y), ann=FALSE, axe=FALSE, type="o ", col="red")
axis(1, at = 1:max(x), labels = letters[1:max(x)])
axis(2)

# points(x, y[,1]) #这样画线和点的颜色一样,不太方便控制
lines(x, y[,2], col="green")
# points(x, y[,2], pch=2)
lines(x, y[,3], col="blue")
# points(x, y[,3], pch=3)

box(lty='1373',col='red')

=================================================

axis(side=1,at=seq(0,max(x),1),outer=FALSE, tick=TRUE,lwd.ticks=1,lty=1,tck=0.01, labels=FALSE)

#tick     a logical value specifying whether tickmarks and an axis line should be drawn.

#lwd     line width

#lwd.tick   line width of tick mark

#tck    tick的长度占图的长(应该对应纵坐标上的tick mark)或者宽的比例
axis(side=2)
mtext("a", side=1,at=1)
mtext("b", side=1,at=2)
mtext("c", side=1,at=3)
mtext("d", side=1,at=4)
mtext("e", side=1,at=5)
mtext("f", side=1,at=6)
mtext("h", side=1,at=7)
mtext("i", side=1,at=8)
mtext("jj", side=1,at=9)
mtext("k", side=1,at=10)

• 本文已收录于以下专栏：

举报原因： 您举报文章：R plot 画图 色情 政治 抄袭 广告 招聘 骂人 其他 (最多只允许输入30个字)