All right, let's say I have the following plot.
df = data.frame(date=c(rep(2008:2013, by=1)), value=c(303,407,538,696,881,1094)) barplot(df$value, main="TITLE", col="gray", ylab="People", xlab="Years")
How can I change the background to navy blue?
I know this is possible with ggplot2, but not sure if I can do this with base graphics.
Color pickerUse the color pickers to change the panel area (left) and the plot region (right), or to generate random colors pressing the blue button. Then you can copy the colors and use them in your plots.
par(bg ="") is used to change the background color in base R. Let's try an example. The code above used par to change the background color of the plot in R. The default color is white .
set_facecolor() method is used to change the inner background color of the plot. figure(facecolor='color') method is used to change the outer background color of the plot.
Like
par(bg = 'blue') # Now do plot
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With