I have data from 2 populations. I\'d like to get the histogram and density plot of both on the same graphic. With one color for one population and another color for the other on
I suggest this ggplot2 solution:
ggplot(todo, aes(valores, color=grupo)) + geom_histogram(position="identity", binwidth=3, aes(y=..density.., fill=grupo), alpha=0.5) + geom_density()
@skan: Your attempt was close but you plotted the frequencies instead of density values in the histogram.