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
xl
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)))