Ire*_*ene 7 graphics r legend legend-properties
我无法正确设置图例的位置,我试图玩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)
Run Code Online (Sandbox Code Playgroud)
正如在重新启动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)
Run Code Online (Sandbox Code Playgroud)
解决了我的问题.