[R] several plots in one

Warnes, Gregory R gregory.r.warnes at pfizer.com
Wed Feb 1 17:09:23 CET 2006


If you want two series of plotted confidence intervals, first plot one series using plotCI with the standard arguments, then call plotCI a second time with add=TRUE.  For example:


       data(state)
       tmp   <- split(state.area, state.region)
       means <- sapply(tmp, mean)
       stdev <- sqrt(sapply(tmp, var))
       n     <- sapply(tmp,length)
       ciw   <- qt(0.975, n) * stdev / sqrt(n)

       # First series
       plotCI(x=means, uiw=ciw)

	 # Second series
       plotCI(x=means+1e5, uiw=ciw, add=T)


Note that you may need to manually specify xlim and ylim to ensure that the second series fits on the plot.

-Greg

> -----Original Message-----
> From: r-help-bounces at stat.math.ethz.ch
> [mailto:r-help-bounces at stat.math.ethz.ch]On Behalf Of JeeBee
> Sent: Wednesday, February 01, 2006 6:02 AM
> To: r-help at stat.math.ethz.ch
> Subject: [R] several plots in one
> 
> 
> Can anyone tell me how I can supply more than one graph to plotCI
> (gplots) at once?
> 
> Below is what I tried, also with rbind instead of cbind.
> What is the way to do this (in general, I think)?
> 
> Problem is that lines of 1-st and 2-nd series are mixed, 
> while they have
> nothing to do with each other.
> 
> I also tried calling plotCI with argument add=TRUE, which 
> didn't seem to
> work (that is actually what I wanted I think).
> (It should look the same as if I called plotCI twice with same
> labels/xlim/ylim/etc.)
> 
>   plotCI(x = cbind(x1,x2),
>          y = cbind(means1,means2), # means1 == ci1["Estimate",]
>          xlim = c(0,100), #ylim = c(0.2,0.5),
>          ylab = "System welfare", 
>          pch = 7, col = c("red","blue"), type = "b",
>          uiw = cbind(uiw1,uiw2))
> 
> Thanks in advance,
> JeeBee.
> 
> ______________________________________________
> R-help at stat.math.ethz.ch mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide! 
http://www.R-project.org/posting-guide.html
----------------------------------------------------------------------
LEGAL NOTICE\ Unless expressly stated otherwise, this messag...{{dropped}}




More information about the R-help mailing list