Re: [R] two histograms in the same graph

2008-01-25 Thread hadley wickham
On Jan 25, 2008 2:04 PM, Domenico Vistocco <[EMAIL PROTECTED]> wrote: > You could use ggplot2: > > library(ggplot2) > x=rnorm(100) > y=rnorm(100) > df=melt(data.frame(x,y)) > #for "vertical" histogram > ggplot(data=df,aes(x=value))+geom_histogram()+facet_grid(.~variable) > #for "horizontal" histogr

Re: [R] two histograms in the same graph

2008-01-25 Thread Domenico Vistocco
You could use ggplot2: library(ggplot2) x=rnorm(100) y=rnorm(100) df=melt(data.frame(x,y)) #for "vertical" histogram ggplot(data=df,aes(x=value))+geom_histogram()+facet_grid(.~variable) #for "horizontal" histogram ggplot(data=df,aes(x=value))+geom_histogram()+facet_grid(.~variable) + coord_flip

Re: [R] two histograms in the same graph

2008-01-25 Thread David Daniel
You might look at the method histbackback (back-to-back histograms) in package Hmisc. At the time I looked at this package about a year ago, I could not get it working on my Mac, so I don't actually know what the results look like, but I have created them before in XLispStat and found them

Re: [R] two histograms in the same graph

2008-01-25 Thread Jim Lemon
Juan Pablo Fededa wrote: > Dear Contributors: > > I have two vectors x and z, and I want to display the histograms of both > vectors in the same graph, x in red bars, z in blue bars. > If you have any clue on how to do that, I will be very glad to hear it!! > Thanks in advance again, > Hi Jua

Re: [R] two histograms in the same graph

2008-01-24 Thread Peter Dalgaard
Duncan Murdoch wrote: > On 1/24/2008 9:43 AM, Juan Pablo Fededa wrote: > >> Dear Contributors: >> >> I have two vectors x and z, and I want to display the histograms of both >> vectors in the same graph, x in red bars, z in blue bars. >> If you have any clue on how to do that, I will be very gla

Re: [R] two histograms in the same graph

2008-01-24 Thread Duncan Murdoch
On 1/24/2008 9:43 AM, Juan Pablo Fededa wrote: > Dear Contributors: > > I have two vectors x and z, and I want to display the histograms of both > vectors in the same graph, x in red bars, z in blue bars. > If you have any clue on how to do that, I will be very glad to hear it!! It's hard to

Re: [R] two histograms in the same graph

2008-01-24 Thread ONKELINX, Thierry
That's an easy one with ggplot2. library(ggplot2) dataset <- data.frame(variable = gl(2, 50, labels = c("x", "z")), value = c(runif(50), rnorm(50))) ggplot(data = dataset, aes(x = value, fill = variable)) + geom_histogram(position = "dodge") + scale_fill_manual(values = c("red", "blue"), guide = "