简体   繁体   English

图例中项目之间的空间

[英]Space between items in the legend

I am creating a legend without a plot, but part of the items are left out, how can I avoid stuff kept out? 我正在创建没有图例的图例,但是其中一些项被遗漏了,如何避免东西被拒之门外? A possible way would be to reduce the space between the items. 一种可能的方法是减少项目之间的空间。 That's what I have done 那就是我所做的

plot(1, type="n", axes=FALSE, xlab="", ylab="") 
legend("bottomleft", bty = "n",inset = c(-0.2, 0),
       legend = c("AA","ABC","DEF","GHI","LMO","AAABBB","ABC ABCDEF"), 
       col=c(AA = "#8b5a00", ABC = "#5d8f21",  DEF =  "#9f69ee", 
             GHI = "#ec4e01", LMO = "#b9c000", AAABBB = "#12a0a5", "ABCDEF" = "tan1"), 
       pch=16,  cex=1, xjust=0.5, yjust=0.5, horiz=T, xpd = TRUE, x.intersp=0.5)

The plot window needs to be sufficiently large, you can just call it directly in pdf() or png() with enough width: 绘图窗口必须足够大,您可以直接在pdf()png()以足够的宽度直接调用它:

png("test.png", width=1000)
plot.new()
# Your legend
dev.off()

I have found that text.width can control width legend text horizontally (x coordinates), first value refers to the position of the first item. 我发现text.width可以水平控制宽度图例文本(x坐标),第一个值是指第一个项目的位置。

legend("bottomleft", text.width=c(0,0.046,0.052,0.056,0.056,0.059,0.069) ... legend("bottomleft", text.width=c(0,0.046,0.052,0.056,0.056,0.059,0.069) ...

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM