[R] how to draw two histograms in one figure

Jason Turner jasont at indigoindustrial.co.nz
Wed Jun 5 00:33:22 CEST 2002


On Tue, Jun 04, 2002 at 01:49:40PM -0700, Roman Sasik wrote:
> How do you draw two histograms in one figure? Two separate uses of the 
> "hist" function always produce two separate figures...  Thanks, Roman

Side by side?  Check out help(layout) and help(par).  For the latter, 
the mfcol and mfrow arguemnts are what you're after.  Follow the commands
that are used when you type

par(ask=TRUE)
example(hist)
par(ask=FALSE)

Another possibility is the lattice library histogram() function.

par(ask=TRUE)
library(lattice)
example(histogram)
par(ask=FALSE)

Two overlaid in the same plot?  

<opinion>
Ugly.  Use density plots instead, whenever possible.
</opinion>

The density() function provided is good for this, and so is the sm
library's sm.density() function.

par(ask=TRUE)
example(density)
par(ask=FALSE)

Cheers

Jason
-- 
Indigo Industrial Controls Ltd.
64-21-343-545
jasont at indigoindustrial.co.nz
-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !)  To: r-help-request at stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._



More information about the R-help mailing list