r - Is there a `par()` setting for plot area color? -
i wondering if there easy way color plot area? believe par()$bg setting defines color background of entire device, , have been applying low-level plotting command polygon add colored rectangle 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 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 way this, if there more straightforward way in par settings, love know. in advance advice.
i'm pretty there's no par argument that, itself, want.
here though simpler approach yours. uses plot.default()'s panel.first argument plot, in background, single huge filled point centered @ origin. point's extent @ least googol cubed units in every direction, , i've confirmed works r's native windows plot device, , pdf , png devices: appears pretty general solution.
## example plot(x=1, y=2, panel.first={points(0, 0, pch=16, cex=1e6, col="grey90") grid(col="white", lty=1)}) ## or, repeated use, make function: ggbg <- function() { points(0, 0, pch=16, cex=1e6, col="grey90") grid(col="white", lty=1) } plot(x=1, y=2, panel.first=ggbg()) 
## works plots running out 1e300 in each direction plot(x=-1e300, y=1e300, panel.first=ggbg())
Comments
Post a Comment