图例中项目之间的空格

时间:2015-11-26 00:29:36

标签: r legend

我正在创建一个没有情节的传奇,但部分项目被遗漏了,我怎样才能避免遗漏的东西? 一种可能的方法是减少物品之间的空间。这就是我所做的事情

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)

2 个答案:

答案 0 :(得分:1)

绘图窗口需要足够大,您可以直接在png()png("test.png", width=1000) plot.new() # Your legend dev.off() 中调用它,并且宽度足够大:

:medium

答案 1 :(得分:0)

我发现text.width可以水平控制宽度图例文本(x坐标),第一个值指的是第一个项目的位置。

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