[R] plot bg color problem

Duncan Murdoch murdoch at stats.uwo.ca
Sun Apr 2 14:56:36 CEST 2006


On 4/2/2006 8:03 AM, Fred J. wrote:
> Dear R users, 
>  
>  this line below is not painting the background black but it is still white.
>  plot(x,y[x], type='s', bg='black', col='yellow', ylim=range(y))
>  I am running R 2.2.1

See ?plot.default.

You need

x <- y <- 1:10

par(bg='black')
plot(x,y[x], type='s', col='yellow', ylim=range(y))

but you'll probably want to change some more colours, using par() or in 
the plot call, e.g.

par(bg='black', fg='white', col='green', col.axis='red', 
col.lab='magenta', col.main='blue', col.sub='cyan')

plot(x,y[x], type='s', col='yellow', ylim=range(y), main='main', sub='sub')

(which is not the most beautiful plot, but it does show you which 
settings affect which parts of the plot).

Duncan Murdoch




More information about the R-help mailing list