r legend麻烦,如何更改图例中的文字大小

zhu*_*oer 26 plot r legend

我认为cex不起作用.Cex将改变传奇的整体规模.但我只想扩大文字大小.任何命令都会有帮助?

Jil*_*ina 34

是的!pt.cex = 1,cex根据需要设置和更改:

plot(c(1,1))
legend("topleft", "Legend", cex=1.3, pch=1, pt.cex = 1)
Run Code Online (Sandbox Code Playgroud)


rba*_*att 6

您可以将点的cex与图例的其余部分分开设置.不过,这仍然会使盒子变小.您尝试做的更具体的示例可能会有所帮助.但是,看看这是否解决了您的问题:

plot(rnorm(10))
legend("top", legend="test", pch=21) #everything is normal sized (cex=1 default from par())
legend("topleft", legend="test", pch=21, cex=0.5) #everything is small
legend("topright", legend="test", pch=21, pt.cex=1, cex=0.5) #the point is normal, but the rest is small
Run Code Online (Sandbox Code Playgroud)

祝你好运:)