11 plot visualization r
我的情节中有一个传奇,但我正在尝试增加字体大小以使其适合图例框.当我尝试增加以下cex
定义时.盒子变大了,而文字仍然很小.
码:
legend(0,16, c("Available vCPUs","Added vCPUs (1 per iteration ) "),col=c('red','black'),cex=0.39,lty=1:1,lwd=2
)
情节摘录:
Wor*_*ice 12
第一种方法:
尝试在绘制图例之前设置字体大小.
x <- y <- rnorm(100, 0, 1)
plot(x, y, type = "n")
## here you set the font size default to `x`, in this example 0.5
## save defaults in `op`
op <- par(cex = 0.5)
legend("topright", legend = "foo legend", pch = 1, bty = "n")
Run Code Online (Sandbox Code Playgroud)
## here you set cexto 1.5
## save new defaults in `op`
op <- par(cex = 1.5)
legend("topright", legend = "foo legend", pch = 1, bty = "n")
Run Code Online (Sandbox Code Playgroud)
第二种方法:
将pt.cex
参数保持为1,同时在图例调用cex
内部尝试不同的值.记得删除op
.
x <- rnorm(100, 10, 4)
y <- rnorm(100, 10, 4)
plot(x, y, type = "n")
## I tried to feed cex with 1.5 and 0.5. The font size changes while the points remain unchanged.
legend("topleft", "Legend", cex=0.5, pch=1, pt.cex = 1)
Run Code Online (Sandbox Code Playgroud)