Dear Ben, thank you very much for your prompt reply.
but I'm afraid I'm missing something: when I apply your function pmulthist I obtain exactly the same results as with multhist (with the y axis representing frequencies rather than a probability). I was checking but couldn't find the problem (*"allhist" is clearly set to be freq=False*) I would appreciate a lot if you can point out what I'm missing. Ahimsa # This is what I do: library(plotrix) pmulthist <- function (x, breaks = "Sturges", ...) { allhist <- hist(unlist(x), breaks = breaks, plot = FALSE, freq=FALSE) combhist <- t(sapply(x, function(z) hist(z, breaks = allhist$breaks, plot = FALSE)$counts)) barplot(combhist, beside = TRUE, names = signif(allhist$mids, 2), ...) } mh <- list(rnorm(200, mean=200, sd=50), rnorm(200, mean=250, sd=50)) pmulthist(mh) # y-axis appears as frequency values multhist(mh) # the histogram is identical to previous On 11/30/06, Ben Bolker <[EMAIL PROTECTED]> wrote: > > ahimsa campos-arceiz <ahimsa <at> camposarceiz.com> writes: > > > > > Hi, > > > > I'm plotting a multiple histogram using the function multhist {package > > plotrix}, something like: > > > > library(plotrix) > > mh <- list(rnorm(200, mean=200, sd=50), rnorm(200, mean=250, sd=50)) > > multhist(mh) > > > > In this graph y-axis represents the frequency of observations.... but I > > would like it to be scaled into relative frequencies, > > > > does anybody know how to do this with multhist or similar function? > > > > thanks a lot, > > > > Ahimsa > > > > In its current form, multhist doesn't allow the > freq=FALSE or prob=TRUE arguments to be passed to > hist() (the ... argument passes optional arguments > to barplot, not hist). You could hack it as follows: > > pmulthist <- > function (x, breaks = "Sturges", ...) > { > allhist <- hist(unlist(x), breaks = breaks, plot = FALSE, freq=FALSE) > combhist <- t(sapply(x, function(z) hist(z, breaks = allhist$breaks, > plot = FALSE)$counts)) > barplot(combhist, beside = TRUE, names = signif(allhist$mids, > 2), ...) > } > > ______________________________________________ > R-help@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 > and provide commented, minimal, self-contained, reproducible code. > -- ahimsa campos-arceiz www.camposarceiz.com [[alternative HTML version deleted]] ______________________________________________ R-help@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 and provide commented, minimal, self-contained, reproducible code.