I searched for this but I only came with this similar question but labelling the count values in stacked histogram. What I want to do is that label just one price
value on top of each histogram bar.
using the similar histogram-ggplot-show-count-label-for-each-bin-for-each-category
ggplot(aes(x = price ), data = diamonds) +
geom_histogram(aes(fill = cut ), binwidth=1500, colour="grey20", lwd=0.2) +
stat_bin(binwidth=1500, geom="text", colour="white", size=3.5,
aes(label=..count.., group=cut, y=0.8*(..count..))) +
scale_x_continuous(breaks=seq(0,max(diamonds$price), 1500))
When I change label=..count..
to ..price..
I get
Error in FUN(X[[i]], ...) : object 'price' not found
How I can we put price
value on top of each histogram?
thanks in advance!