position legend of a stacked bar plot

后端 未结 4 897
余生分开走
余生分开走 2020-12-29 04:57

I am trying to create a stacked bar plot, but I cannot position the legend so that it does not overlap any of the bars. I have tried adjusting the margins, setting xl

4条回答
  •  遥遥无期
    2020-12-29 05:52

    With margins

    par(mfrow=c(1, 1), mar=c(5, 5, 4, 8))
    barplot(y, col = 1:nrow(y), ylab="My Variables", legend.text = TRUE, 
            args.legend = list(x = "topright", bty = "n", inset=c(-0.15, 0)))
    

提交回复
热议问题