I am trying to make striped plots (with altering white and grey background) when plotting 5 box plots in a row. Why is the background color not being applied to the whole plot in my code? The background color does change when I plot the box plots individually.
set.seed(42)
dev.off()
windows(width=6, height=4)
par(mfrow=c(1,5))
par(mar=c(2,4,1,1)) # bottom, left, top and right
par(bg = 'white')
boxplot(rnorm(20), ylab = "A")
title(xlab="n = 54", line=0)
par(bg = 'grey')
boxplot(rnorm(20), ylab = "B")
title(xlab="n = 54", line=0)
par(bg = 'white')
boxplot(rnorm(20), ylab = "C")
title(xlab="n = 54", line=0)
par(bg = 'grey')
boxplot(rnorm(20), ylab = "D")
title(xlab="n = 26", line=0)
par(bg = 'white')
boxplot(rnorm(20), ylab = "E")
title(xlab="n = 6", line=0)
To clarify, I want the area inside red rectangles in the figure below to be grey.