Nathaniel Street
2005-Mar-10 20:14 UTC
[R] Transparent colors OR two series on one histogram
Hi, I want to be able to plot a single histogram of a measured trait with trait values from two conditions on the same histogram to allow easy comparison. I have previously done this in excel by plotting the two series on a single bargraph having calculated frequencies in bins. You then get one condition plotted immediately to the right of the other. I hope that makes sense? I don't know if this is possible in R? If not, I could plot the second one on top of the first i.e. hist(x) hist(y,add=TRUE) but i would need to set one as having a semi-transparent color so that where the two sets of are plotted on top of each other, you can see the frequency of the first series 'behind' the second. Can anyone help me do this? It would be another step towards never using excel again :) Thanks
On Thu, 10 Mar 2005, Nathaniel Street wrote:> Hi, > > I want to be able to plot a single histogram of a measured trait with trait > values from two conditions on the same histogram to allow easy comparison. > > I have previously done this in excel by plotting the two series on a single > bargraph having calculated frequencies in bins. You then get one condition > plotted immediately to the right of the other. I hope that makes sense? > > I don't know if this is possible in R?You can do it for bar plots, but not for histograms. Look at barplot(beside=TRUE)> If not, I could plot the second one on top of the first i.e. > > hist(x) > hist(y,add=TRUE) > > but i would need to set one as having a semi-transparent color so that where > the two sets of are plotted on top of each other, you can see the frequency > of the first series 'behind' the second.Semitransparent colors are available for the pdf() and quartz() devices. They were described by Paul Murrell in R News Vol 4 No 2. -thomas