Friday, April 5, 2013

RG10 # plotting multiple suprimposed histograms or density plots

#data
set.seed(1233)

data1 <- data.frame(pop =c(rep("A x B", 200), rep("A x C", 200), rep("B x C", 200) ) ,   var1 =  c(rnorm(1000, 90,10), rnorm(1000, 50, 10), rnorm(1000, 20, 30)))
#
plot using ggplot2
require(ggplot2)
qplot( var1, data = data1, geom = "density" , group = pop, fill = pop, alpha=.3) + theme_bw( )

qplot( var1, data = data1, geom = "histogram" , group = pop, fill = pop, alpha=.3) + theme_bw( )





 

No comments:

Post a Comment

Note: Only a member of this blog may post a comment.