library("ggplot2") ggplot(iris,aes(x=Petal.Length,y=..density..,fill=Species))+ geom_histogram(position="dodge")+ geom_density(alpha=0.5)