Plotting legend outside of multiple plot in R

by Kate   Last Updated October 11, 2018 17:26 PM

I'm trying to plot the legend outside of multiple plot use this code:

par(mfrow=c(3,3))
    par(oma = c(4, 2, 1, 1))
    plot(1)
    plot(2)
    plot(3)
    plot(4)
    plot(5)
    plot(6)
plot(7)
plot(8)
plot(9)
    legend("bottom", inset = 0, legend = c("a", "b", "c", "d"), col= c("steelblue4", "lightseagreen", "paleturquoise", "gray87"),  bty = "n", horiz = T,  lwd = 5, xpd = T)

But the legend is inside of one of plot region: legend

How can I fix this?

Tags : r plot legend


Related Questions




How to add a legend to a multi-figure plot?

Updated September 24, 2018 20:26 PM

Placing two dots next to each other in R legend

Updated July 31, 2018 23:26 PM