Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Change background color of R plot

Tags:

plot

r

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.

like image 846
ATMathew Avatar asked Aug 29 '11 22:08

ATMathew


People also ask

How do I change the background color of my plot in R?

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.

How do you change the background on a graph in R?

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 .

How do you change the background color of the plot?

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.


1 Answers

Like

par(bg = 'blue') # Now do plot 
like image 149
Owen Avatar answered Sep 20 '22 02:09

Owen