You can choose the background of your plot by using the command par(bg=).
x <- c(1,2,3,4,5,6)
y <- c(3,6,9,4,3,4)
par(bg=’lightgreen‘)
plot(x,y, type = ‚l‘)
As you can see, the command par(bg=) sets the color of the whole plotting area. If you want change the color of the plot region itself, it is a little trickier. You have to get the coordinates of the plot area rectangle and color it by using the rect command. The following example shows the previously created plot, but this time only the area within the box is colored. At first we create an empty plot. Then we use rect to color it. At least we draw the plot a second time with the according content. The command par(new=TRUE) enables overplotting. So the second plot is created on top of the first one.
x <- c(1,2,3,4,5,6)
y <- c(3,6,9,4,3,4)
plot(x,y, type = ’n‘)
rect(par(‚usr‘)[1], par(‚usr‘)[3], par(‚usr‘)[2], par(‚usr‘)[4], col = ‚lightgreen‘)
par(new=TRUE)
plot(x,y, type = ‚l‘)