在R中设置图例的大小

时间:2018-06-26 16:20:59

标签: r plot legend figure

每个人。我在R studio中使用绘图功能。下面是我的情节。如您所见,图形图例框太大,我想将其设置得较小。我试图修改相同的参数,但是没有用。 我的代码是:

legend("topleft", legend=names(attr(colcode, "table")), 
       fill=attr(colcode, "palette"), cex=0.6,bg = "white", text.width = 1)

enter image description here

1 个答案:

答案 0 :(得分:0)

您指定了text.width = 1,它是图形的整个宽度。如果减小text.width,它将看起来不错。尝试

legend("topleft", legend=names(attr(colcode, "table")), 
       fill=attr(colcode, "palette"), cex=0.6,bg = "white", text.width = 0.1)

您可能需要进一步减少它。