0
我在R中的以下情節包含堆疊在彼此的頂部兩個曲線圖:調準多個圖軸中的R
time <- seq(0,72,12)
betagal.abs <- c(0.05,0.18,0.25,0.31,0.32,0.34,0.35)
cell.density <- c(0,1000,2000,3000,4000,5000,6000)
layout(matrix(c(1,2,2), 3, 1, byrow=TRUE))
par(mar=c(1, 4, 4, 6) + 0.1)
othertime <- seq(0,48,12)
otherbetagal <- c(0.05,0.18,0.25,0.31,0.32)
plot(othertime,
otherbetagal+c(0.13072000, -0.38438639, 0.16157348,
-0.07862935, 1.72706526),
xlim=c(0,70))
## add extra space to right margin of plot within frame
par(mar=c(5, 4, 4, 6) + 0.1)
## Plot first set of data and draw its axis
plot(time, betagal.abs, pch=16, axes=FALSE, xlab="", ylab="",
xlim=c(0,70),
type="b",col="black", main="Mike's test data")
axis(2, col="black",las=1) ## las=1 makes horizontal labels
mtext("Beta Gal Absorbance",side=2,line=2.5)
box()
## Allow a second plot on the same graph
par(new=TRUE)
## Plot the second plot and put axis scale on right
plot(time, cell.density, pch=15, xlab="", ylab="",
axes=FALSE, type="b", col="red")
## a little farther out (line=4) to make room for labels
mtext("Cell Density",side=4,col="red",line=4)
axis(4, col="red",col.axis="red",las=1)
## Draw the time axis
axis(1,pretty(range(time),10))
mtext("Time (Hours)",side=1,col="black",line=2.5)
不幸頂端x軸和底部x軸不對齊。我希望他們一致。如果仔細觀察,刻度線會接近但不對齊 - 即,您無法從頂部繪圖中的「70」勾出直線畫出垂直線,在底部繪圖中勾選「70」。如何解決?