减少条形图中图例区域的大小

时间:2014-06-23 08:36:38

标签: r plot legend

我无法在此图中减小图例的大小。有人可以帮帮我吗?我希望它看起来是正确的,但不超过绘图区高度的20%

a <- c(3, 2, 2, 2, 1, 2 )
barplot(a, beside = T,
col = 1:6, space = c(0, 2))
legend("topright", legend = c("a", "b", "c", "d", "e", "f"), fill = 1:6, ncol = 2)

1 个答案:

答案 0 :(得分:35)

cex参数会为您执行此操作。

a <- c(3, 2, 2, 2, 1, 2 )
barplot(a, beside = T,
        col = 1:6, space = c(0, 2))
legend("topright", 
       legend = c("a", "b", "c", "d", "e", "f"), 
       fill = 1:6, ncol = 2,
       cex = 0.75)

The plot