R图例问题,如何更改图例中的文本大小

31

我认为cex无效。cex会改变图例的整个比例尺。但是我只想增大文本大小。是否有任何命令可以帮助我?

2个回答

39

是的!设置 pt.cex = 1 并根据您的需要更改 cex,例如:

plot(c(1,1))
legend("topleft", "Legend", cex=1.3, pch=1, pt.cex = 1)

10

您可以单独为点设置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

祝你好运 :)


网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接