Edward Wijaya <ewijaya <at> gmail.com> writes: > > I have two histograms created separately using > the following code. It creates two separate figures. > > dat <- read.table(file="GDS1096.modelout", head = FALSE ) > > __BEGIN__ > dat <- read.table(file="GDS1096.modelout", head = FALSE ) > > hist(dat$V2, main="AIC Freq", xlab = "\# Component", breaks = 36, xlim = > c(0,max(dat$V2)), col = "dark red", freq = TRUE) > hist(dat$V3, main="BIC Freq", xlab = "\# Component", breaks = 36, xlim = > c(0,max(dat$V2)), col = "blue", freq = TRUE) > __END__ > > How can I joint this two histograms into one figure?
You could use par(mfcol), and if you want the plots closely spaced, play with the margin parameters documented under par(). In most cases, the result is not that satisfactory, so I would recommend using lattice graphics instead, where the pairing is a build-in feature. Dieter par(mfcol=c(1,2)) a = rnorm(100) b = rnorm(100) hist(a) hist(a) library(lattice) dt = data.frame(val =c(a,b),group=rep(c("A","B"),each=100)) histogram(~val|group,data=dt) ______________________________________________ R-help@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.