[R] background colour

Daniel Stepputtis r at stepputtis.net
Tue Jan 15 09:20:17 CET 2008


Dear Brian, thank you for helping. You are right, I was not aware of these two different meaning of bg. I will have a closer look to those help pages (whereas I've consulted 
these pages before I have written the question, but didnt realized the difference).

Best regards
Daniel

Prof Brian Ripley schrieb:
> 'bg' is both a graphics parameter and an argument to plot.default: the 
> two usages have different meanings.  Please study the help (e.g. ?par, 
> ?plot.default, ?points) carefully, since you are confusing the two 
> meanings in your examples.
> 
> On Mon, 14 Jan 2008, Daniel Stepputtis wrote:
> 
>> Dear list,
>>
>> I am using R 2.6 on a Windows XP machine.
>>
>> I divided my device window and tried to set the backgroundcolor for 
>> each plot region/figure region separately. This seems not possible?? A 
>> simple example:
>>
>> # create random numbers
>> a <- rnorm(100)
>> # divide device window
>> par(mfrow=c(1,2))
>> # set the backgroundcolour to "red"
>> # this always affect the total device
> 
> Yes, as documented.
> 
>> par(bg="red")
>> #two plots should be plotted
>> plot(a)
>> hist(a)
>>
>>
>> I have tried to call "bg" within the high-level-graphic function 
>> (plot(bg="red")). Whereas there was no error-message, this has no 
>> effect on the background of this singe plot.
>>
>> I found a meaningfull answer I have found here: 
>> http://finzi.psych.upenn.edu/R/Rhelp02a/archive/21384.html but I was 
>> wondering, whether there is a more easy and explicit way to do it 
>> directly for a given plot in a multiplot environment. Are there 
>> possibilities to do it specifically for the complete figure region or 
>> solely for the complete plot region?
> 
> Yes, but this would be part of the figure whereas what par(bg=) does is 
> not.  So it's down to you to colour the box you want, most easily with 
> rect() as Marc showed in the post you cite.
>




More information about the R-help mailing list