关于绘图区域
概念 | 英文 | 缩写函数 | 释义 |
---|---|---|---|
主绘图 | main plot area | 类比画布,整块画布 | |
绘图边距 | margins | mar() | 画布上想要画的地方的边距 |
外围边距 | out margin area | oma() | 画的图除了坐标轴外的画的东西 |
我们也可以用mai() and omi() 调整边缘,mai()与mar()的区别主要是单位的不同 ,oma与omi的区别主要也是是单位的不同
前者单位为文本行数,后者单位为英寸
一、上面那个图的代码,一行行运的话可以深刻体会画的是哪里
# Margins area 先把边缘确定
par(oma=c(3,3,3,3)) # all sides have 3 lines of space
par(mar=c(5,4,4,2) + 0.1)
# Plot 画图
plot(0:10, 0:10, type="n", xlab="X", ylab="Y") # type="n" hides the points
# Place text in the plot and color everything plot-related red
text(5,5, "Plot", col="red", cex=2)
box(col="red")
# Place text in the margins and label the margins, all in forestgreen
mtext("Margins", side=3, line=2, cex=2, col="forestgreen")
mtext("par(mar=c(b,l,t,r))", side=3, line=1, cex=1, col="forestgreen")
mtext("Line 0", side=3, line=0, adj=1.0, cex=1, col="forestgreen")
mtext("Line 1", side=3, line=1, adj=1.0, cex=1, col="forestgreen")
mtext("Line 2", side=3, line=2, adj=1.0, cex=1, col="forestgreen")
mtext("Line 3", side=3, line=3, adj=1.0, cex=1, col="forestgreen")
box("figure", col="forestgreen")
# Label the outer margin area and color it blue
# Note the 'outer=TRUE' command moves us from the figure margins to the outer margins.
mtext("Outer Margin Area", side=1, line=1, cex=2, col="blue", outer=TRUE)
mtext("par(oma=c(bottom,left,to,right))", side=1, line=2, cex=1, col="blue", outer=TRUE)
mtext("Line 0", side=1, line=0, adj=0.0, cex=1, col="blue", outer=TRUE)
mtext("Line 1", side=1, line=1, adj=0.0, cex=1, col="blue", outer=TRUE)
mtext("Line 2", side=1, line=2, adj=0.0, cex=1, col="blue", outer=TRUE)
box("outer", col="blue")
二、用其他图再次示例,先画一个散点图
plot(x=expdata[,1],y=expdata[,2], type="p", ann=T, axes=T,cex=0.2,
main = "the compare of two sample's expression")`
box()函数可可视化plot绘图区域
# plot区域
box("plot", lty="dashed",col="red",lwd=3)
# figure区域
box("figure",col="blue",lwd=3)
# 绘图边距
box("outer", col="darkgreen",lwd=3)
网友评论