更改条形图图例的位置

时间:2015-02-14 20:23:59

标签: r bar-chart legend

我的传说与我的条形图重叠 - (stackoverflow不允许我发布图片)

我搜索了一些类似的问题但未能解决我的问题。我可以补充一点,我是R的新手。如果有人能提供帮助,我将非常感激。

这是我的剧本

mids<-barplot(mean.growth,beside=T,legend=T, ylim=c(0,0.01), ylab="Growth (mm)")
arrows(mids,mean.growth-se.growth,mids,mean.growth+se.growth,length=0.1, code=3, angle=90)

text(mids,mean.growth+0.003,labels=c("bc","a","b","cd","bc","bcd","cd","d","cd","d","d","cd"))

1 个答案:

答案 0 :(得分:0)

如果您阅读?barplot,您会看到您可以提供要传递给'legend()'的参数列表。明显的建议是设置x参数,如:

barplot(mean.growth,
        beside=T,
        legend=T, 
        args.legend = list(x = 'topleft') # or 'top','bottom','left','right',etc.
        ylim=c(0,0.01), 
        ylab="Growth (mm)")

或展开xlimylim参数以为图例腾出空间。