I plotted this trying to understand how to plot the distribution of each singular feature of my dataframe. So, trying to understand if my procedure was correct I implemented this code to plot rapidly two features.
New <- c(Carm[,3],Carm[,4])
Names <-names(Carm)
Label <-c(Names[1],Names[2])
dat <- data.frame(New)
names(dat)[1] <- Label[1]
names(dat)[2] <- Label[2]
dat <- stack(dat) #I built a new smaller db taking only two features
# Now I use ggplot
ggplot(dat, aes(x=values)) +
geom_histogram(binwidth = 0.5, color = "black",fill ="white") +
geom_density(aes(group=ind, colour=ind, fill=ind), alpha=0.2) +
facet_wrap( ~ ind, ncol=2)
So, my question is : why the densities are so small if compared to the histograms? How can I fix it?


geom_histogram(aes(y=..density..), etc)- Rui Barradasgeom_density(aes(y = after_stat(count * 0.5))). The 0.5 being the binwidth of your histogram. - teunbrand