histogram plot in r ggplot2 code example
Example 1: ggplot2 histogram
library(ggplot2)
ggplot(df, aes(x=weight)) + geom_histogram()
ggplot(df, aes(x=weight)) +
geom_histogram(binwidth=1)
p<-ggplot(df, aes(x=weight)) +
geom_histogram(color="black", fill="white")
p
Example 2: ggplot2 histogram
p+ geom_vline(aes(xintercept=mean(weight)),
color="blue", linetype="dashed", size=1)
ggplot(df, aes(x=weight)) +
geom_histogram(aes(y=..density..), colour="black", fill="white")+
geom_density(alpha=.2, fill="#FF6666")