我想更改图例中线条的宽度。目前我有:
legend(-0.145, 25, c("(Gaussian) Kernel density","fitted normal distribution"),lwd=1.8, cex=0.8,
col=c("black","black"), lty=1:2)
lwd 似乎改变了文字,但不是线的宽度和虚线的宽度,我该怎么做?
我认为你错了,lwd
在你的图例中设置线宽:
比较这个(上图):
plot(rnorm(100)*13)
legend(-0.145, 25, c("(Gaussian) Kernel density","fitted normal distribution"),lwd=0.1, cex=0.8,
col=c("black","black"), lty=1:2)
有了这个(底部图):
plot(rnorm(100)*13)
legend(-0.145, 25, c("(Gaussian) Kernel density","fitted normal distribution"),lwd=3, cex=0.8,
col=c("black","black"), lty=1:2)
您可以使用 legend 函数的参数seg.len
来减小图例的大小。
这里有一个例子:
set.seed(55) # Set the seed of R‘s random number generator
x <- runif(10, min=0, max=100) # Generating random numbers
plot(x, type="l") # plot x as line
legend("topright", "x", lty="solid") # add legend
以及修改功能的相同代码legend
:
plot(x, type="l")
legend("topright", "x", lty="solid",seg.len=0.5) # modify length of the line in the legend