Black Lives Matter. Please consider donating to Black Girls Code today.

How to label the histogram bars with its respective frequency counts for each bin?

Hi, could you please suggest a way to label the plotly Histogram bins with their respective frequency counts on top of each bin in the plot ?

I need help to implement this in R. I tried different combinations, but I’m not able to replicate the ggplot version of it using stat_bin and accessing the counts as …count…

Hey @kchaitanyab,

you can try using add_annotations() to add multiple data annotations https://plot.ly/r/text-and-annotations/#multiple-annotations

Hey, thanks. That works.

Sorry, I’m new to this library and I cannot seem to get this to work at all? But perhaps, my bad, I’m could be doing something wrong or missing the point totally?

Outcome desired is similar to what the the hist() call does R (wherein, count can be enabled or disabled with labels=TRUE) Additionally, I would also like to have percentages on top of the bin in another representation? - Can someone post a simple but complete example?