I would like to plot a histogramme, whereby the y axis shows the proportion of observation in the bin. I tried to use the code as suggested here
https://ggplot2.tidyverse.org/reference/geom_histogram.html
ggplot(data=diamonds, aes(x=carat, after_stat(density))) + geom_histogram(binwidth = 0.05, position="identity", fill = "white", colour = "black")
and here
Normalizing y-axis in histograms in R ggplot to proportion by group
ggplot(data=diamonds, aes(x=carat)) + geom_histogram(aes(y=..density..), binwidth = 0.05, position="identity", fill = "white", colour = "black")
but the y axis range is higher than 1 in both cases.
Also when I decrease the binwidth the range of y axis (i.e. the proportion in the most represented group) becomes higher, which does not make any sense, since the group sizes should decrease if I increase the number of groups.