我尝试将图例放在图表之外。 如你所见,这只是成功的一半。
我必须在哪里更改数字?
par(oma = c(0.1,1,0.1,1.5))
matplot(Profile2007, type = "l", lty = 1, col = colfunc(12),
ylab = "m asl", xlab="Distance along crossprofile [m]")
legend("topright", inset=c(-0.33,-0.0012), legend=1:12, xpd=T,
horiz=F, col=colfunc(12), lty =1)
答案 0 :(得分:0)
您没有提供可重现的示例。因此,很难说出问题出在哪里和哪里。什么是Profile2007?什么是colfunc?所以,我们看不到你有一半成功"。
无论如何,以下内容适用于我模拟某些数据的地方:
Profile2007 <- matrix(rnorm(100*12), 100, 12)
par(oma = c(0.1,1,0.1,1.5))
matplot(Profile2007, type = "l", lty = 1, col = rainbow(12),
ylab = "m asl", xlab = "Distance along crossprofile [m]")
legend("topright", inset = c(-0.05,-0.1), legend = 1:12, xpd = TRUE,
horiz = TRUE, col = rainbow(12), lty = 1, bty = "n")
这就是你想要的吗?
编辑或者如果您想要侧面的图例:
Profile2007 <- matrix(rnorm(100*12), 100, 12)
par(mar = c(5, 4, 4, 6) + 0.1)
matplot(Profile2007, type = "l", lty = 1, col = rainbow(12),
ylab = "m asl", xlab = "Distance along crossprofile [m]")
legend("right", inset = c(-0.17,0), legend = 1:12, xpd = TRUE,
horiz = FALSE, col = rainbow(12), lty = 1, bty = "n")
答案 1 :(得分:0)
谢谢你的回答! 对于那个很抱歉! 您的示例看起来与我想要的类似!
颜色是: colfunc&lt; - colorRampPalette(c(&#34; darkblue&#34;,&#34; lightblue&#34;)) colfunc(12)
2007:12条轮廓线(穿过积累叶的交叉轮廓) 样本:
dput(头(Profile07_6)) 结构(清单(X12 = c)(427.89,427.89,427.93,427.96,427.98, 428),X11 = c(421.36,421.34,421.32,421.28,421.22,421.18), X10 = c(415.81,415.6,415.44,415.23,415.03,414.85),X9 = c(401.35, 401.23,401.11,400.94,400.78,400.7),X8 = c(380.04,379.85, 379.64,379.38,379.15,378.96),X7 = c(358.95,359.13,359.34, 359.56,359.78,359.99),X6 = c(348.31,348.52,348.68,348.83, 348.96,349.11)),. Name = c(&#34; X12&#34;,&#34; X11&#34;,&#34; X10&#34;,&#34; X9&#34;,&#34 ; X8&#34 ;, &#34; X7&#34;,&#34; X6&#34;),row.names = c(NA,6L),class =&#34; data.frame&#34;)
到时候,图表看起来像那样
par(tcl=0.5)
matplot(Profile07_6, type = "l", lty = 1, col = colfunc(7), ylim=c(290,440),
ylab = "m asl", xlab="Distance along crossprofile [m]", main ="2007")
par(tcl=0.5)
minor.tick(ny=5, nx=2, tick.ratio=0.5)
abline(h=350, lty=3, col="grey33")
abline(h=400, lty=3, col="grey33")
abline(h=300, lty=3, col="grey33")
abline(h=290, lty=3, col="grey")
abline(h=310, lty=3, col="grey")
abline(h=320, lty=3, col="grey")
abline(h=330, lty=3, col="grey")
abline(h=340, lty=3, col="grey")
abline(h=360, lty=3, col="grey")
abline(h=370, lty=3, col="grey")
abline(h=380, lty=3, col="grey")
abline(h=390, lty=3, col="grey")
abline(h=410, lty=3, col="grey")
abline(h=420, lty=3, col="grey")
abline(h=430, lty=3, col="grey")
abline(h=440, lty=3, col="grey")
axis(4, at=c(290, 310, 320, 330, 340, 360, 370, 380, 390, 410, 420, 430, 440),
labels=c(290, 310, 320, 330, 340, 360, 370, 380, 390, 410, 420, 430, 440),
col.axis="grey33", las=0, cex.axis=0.7, tck=0.01, col = "grey33", padj = -2.1)