[R] Multiple histograms in one chart

Adaikalavan Ramasamy ramasamy at cancer.org.uk
Mon Mar 14 02:42:32 CET 2005


If you use par(new=TRUE), you are overlaying one graph on top of the
other. In which case, make sure your xlim and ylim are correctly set.

Another way is to split the plotting window. For example

   par(mfrow=c(2,3))
   for(i in 1:6) hist( rnorm(100), main=paste("Histogram", i))

See help("par") for more info.

Regards, Adai


On Sun, 2005-03-13 at 15:15 +0100, Uwe Ligges wrote:
> Werner Wernersen wrote:
> > Hi!
> > 
> > I've searched quite a while and this is probably a
> > very easy question: How do I 
> > prevent a new hist() histogram from clearing the chart
> > window before drawing?
> > 
> > I would like to have several histograms simply drawn
> > on each other in one chart...
> 
> See either ?par
>    par(new=TRUE)
> or try argument add = TRUE in hist, depending on what you want to do 
> exactly.
> 
> Uwe Ligges
> 
> 
> > Thanks for your help!
> >    Werner
> > 
> > In use: win2ksp4 & R 2.0.1
> > 
> > ______________________________________________
> > 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
> 
> ______________________________________________
> 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
>




More information about the R-help mailing list