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

27

我无法减小此图表中图例的大小。能否有人帮忙一下?我希望它出现在右上角,但不能超过绘图区域高度的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个回答

47
< p > 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


1
当我的cex=0.5时,尺寸很好但是文本非常小,我该如何解决这个问题? - Cina
3
我猜你应该把 cex 的值调大一点,然后再使用 pt.cextitle.cex。请查看 legend 函数的帮助文档,输入 ?legend 即可。 - Anders Ellern Bilgrau

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接