I am wondering if there is an easy way to only color the plot area? I believe the par()$bg
setting defines the color for the background of the entire device, and so I have been applying the low-level plotting command polygon
to add a colored rectangle to the entire plot area.
Example
#colored device background
x11()
par(bg="grey90")
plot(x=1, y=2)
grid(col="white", lty=1)
points(x=1, y=2)
#colored plot area only
x11()
plot(x=1, y=2)
usr <- par()$usr
polygon(x=c(usr[1], usr[1], usr[2], usr[2]), y=c(usr[3], usr[4], usr[4], usr[3]), col="grey90")
grid(col="white", lty=1)
points(x=1, y=2)
This might be the only way to do this, but if there is a more straightforward way in the par
settings, I would love to know. Thanks in advance for any advice.