Re: [R] Backgrounds in Multiple Plots made with "fig"

From: Paul Murrell <p.murrell_at_auckland.ac.nz>
Date: Mon, 07 Jul 2008 15:18:38 +1200

Hi

Tom La Bone wrote:
> The following code was adapted from an example Vincent Zoonekynd gave on his
> web site http://zoonek2.free.fr/UNIX/48_R/03.html:
>
> n <- 1000
> x <- rnorm(n)
> qqnorm(x)
> qqline(x, col="red")
> op <- par(fig=c(.02,.5,.5,.98), new=TRUE)
> hist(x, probability=T,
> col="light blue", xlab="", ylab="", main="", axes=F)
> lines(density(x), col="red", lwd=2)
> box()
> par(op)
>
> How can I make the background in the small box in the upper left-hand corner
> be a different color than the background in the main plot and erase any of
> the main plot that happens to be behind the box?

Here's one way ...

n <- 1000
x <- rnorm(n)
qqnorm(x)
qqline(x, col="red")
op <- par(fig=c(.02,.5,.5,.98), new=TRUE) plot.new()
usr <- par("usr")
rect(usr[1], usr[3], usr[2], usr[4], col="wheat") par(new=TRUE)
hist(x, probability=T,

     col="light blue", xlab="", ylab="", main="", axes=F) lines(density(x), col="red", lwd=2)
box()
par(op)

Paul

> Tom
>
>
>
>

-- 
Dr Paul Murrell
Department of Statistics
The University of Auckland
Private Bag 92019
Auckland
New Zealand
64 9 3737599 x85392
paul_at_stat.auckland.ac.nz
http://www.stat.auckland.ac.nz/~paul/

______________________________________________
R-help_at_r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.
Received on Mon 07 Jul 2008 - 04:26:32 GMT

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Mon 07 Jul 2008 - 04:31:50 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.

list of date sections of archive