As the title says: How can I plot a legend outside the plotting area when using base graphics?
I thought about fiddling around with layout
Recently I found very easy and interesting function to print legend outside of the plot area where you want.
Make the outer margin at the right side of the plot.
par(xpd=T, mar=par()$mar+c(0,0,0,5))
Create a plot
plot(1:3, rnorm(3), pch = 1, lty = 1, type = "o", ylim=c(-2,2))
lines(1:3, rnorm(3), pch = 2, lty = 2, type="o")
Add legend and just use locator(1) function as like below. Then you have to just click where you want after load following script.
legend(locator(1),c("group A", "group B"), pch = c(1,2), lty = c(1,2))
Try it