图例:控制文本之间的空间

时间:2018-08-23 13:48:58

标签: r plot legend

在图例中,我想增加文本之间的间距。我知道我必须修改text.width参数,但是这样做确实不会增加两个块之间的空间(参见图片)。

代码如下:

par(mfrow=c(1,1))
Nfact = 14
Nrows = 2
Ncols = 8
MyOrder = as.vector(matrix(1:(Nrows*Ncols), nrow=Nrows, ncol=Ncols, byrow=T))

MyCol <- c("white","blue","red","orange",
           "white","blue","red","orange",
           "white","blue","red","orange",
           "white","blue")
x <- 1:Nfact
MyLab <- c("Scen1:",TeX("$2\\cdot \\lambda$"),TeX("$3\\cdot \\lambda$"),TeX("$5\\cdot \\lambda$"),
           "Scen2:",TeX("$2\\cdot \\lambda$"),TeX("$5\\cdot \\lambda$"),TeX("$10\\cdot \\lambda$"),
           "Scen3:",TeX("1.5 year"),TeX("3 years"),TeX("6 years"),
           "Scen4:",TeX("DR testing at baseline"))

plot.new()
legend("center", MyLab[MyOrder], fill = MyCol[MyOrder], ncol = Ncols, border=NA,x.intersp = 0.2,text.width = c(rep(c(c(0.01,rep(0.03,3)),c(20,rep(20,3))),2))[MyOrder],box.col = NA)

这是图片: increase the space in blue

0 个答案:

没有答案