Skip to content

histogram-like plot - multiple bars side by side

3 messages · Jörg Groß, Greg Snow

#
Hi,

I found this example for producing multiple histograms;

  require(plotrix)
  l <- list(rnorm(50),rnorm(50,sd=2),rnorm(50,mean=3))
  multhist(l)


Now I want something like that, for creating multiple density  
distributions (in one plot).

But I have two variables for one density distribution and "multhist"  
only allows me to add one variable;
   x <- seq(from=0, to=14, by=1)
   y <- dbinom(x, 14, 0.7, log = FALSE)


Is there a way to make a histogram-like plot with multiple bars side  
by side (for different distributions) like in the example?
#
Do you mean something like this:

x <- 0:14
y1 <- dbinom(x,14,0.7)
y2 <- dbinom(x,14,0.5)
y3 <- dbinom(x,14,0.3)

barplot( rbind(y1,y2,y3), names=x, beside=TRUE)

Hope this helps,

--
Gregory (Greg) L. Snow Ph.D.
Statistical Data Center
Intermountain Healthcare
greg.snow at imail.org
801.408.8111
#
Thanks!
That helped a lot.


Am 29.09.2008 um 22:13 schrieb Greg Snow: