Hi all, I want to draw a histgram for each row of a matrix and compare them. However the plot I got does not have the same y range and x range, which makes it difficult to make the comparison. Is there a easy way to fix the x range and y range in a xy plot for several plots, instead of specifying them for each plot. The following is my code for generalizing the matrix and draw the histogram.
############gen is the function to generate the dta gen <- function(m, rho) { library(MASS) set.seed(103) theta <- 0 theta1 <- 2 pi0 <- 0.9 mzero <- pi0*m mean <- c(rep(theta, mzero), rep(theta1,m-mzero)) J <- rep(1, m) var <- function(rho) {(1-rho)*diag(m)+ rho*J%*%t(J)} t <- mvrnorm(1, mean, var(rho)) return(t) } ####### w is the matrix. A histgram is drawn for each of the rows. n <- 1000 r <- seq(0,0.9, by=0.1) w <- matrix(0, ncol=n, nrow=length(r)) for (i in 1: length(r)){w[i,]<- gen(n,r[i])} par(mfrow=c(2,5)) hist(w[1,], breaks=100) hist(w[2,], breaks=100) hist(w[3,], breaks=100) hist(w[4,], breaks=100) hist(w[5,], breaks=100) hist(w[6,], breaks=100) hist(w[7,], breaks=100) hist(w[8,], breaks=100) hist(w[9,], breaks=100) hist(w[10,], breaks=100) ############################## Thank you ! Li [[alternative HTML version deleted]] ______________________________________________ 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.