[英]R: positioning of the legend and length of the lines in the legend
我无法设置图例的位置正确,我试图玩弄xjust
和ncol
,但它仍然会出现在图形的中间。
你能帮助它将它与边界对齐(左边或右边我不在乎)?
此外,是否可以在图例中画出较短的线条? 这些看起来太长了。
par(mar=c(5,4,4,5)+.1)
plot(1:109,rnorm(109), type="l",col="blue", lwd=2,
main="Compare signal and std deviation MC3 ch44",
ylab="signal", xlab="locations")
par(new=TRUE)
plot(1:109, rnorm(109), ylab="",xlab="", type="l",
col="red",xaxt="n",yaxt="n", lwd=2)
axis(4)
mtext("std. deviation",side=4,line=3)
legend("topright",col=c("blue", "red"), lwd=2,
legend=c("signal","std dev"), cex=0.85, bty="n", xjust=1)
正如在重新启动R会话和使用的注释中所指出的那样
legend("topright",col=c("blue", "red"), lwd=2,
legend=c("signal","std dev"), cex=0.85, bty="n", xjust=1, seg.len=0.5)
解决了我的问题。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.