Can't reproduce geom_bar example

I’m trying the stacked bar chart example using ggplot and don’t get the correct values in the tooltip. Rather than showing the value for each variable (e.g. F1/500) as in the online example, it shows a cumulative sum for that bar (F1/800).

Session info:
R version 3.3.2 (2016-10-31)
Platform: x86_64-apple-darwin13.4.0 (64-bit)
Running under: macOS Sierra 10.12.1
plotly_4.5.6 ggplot2_2.2.0


DF <- read.table(text="Rank F1     F2     F3
1    500    250    50
2    400    100    30
3    300    155    100
4    200    90     10", header=TRUE)

DF1 <- melt(DF, id.var="Rank")

p <- ggplot(DF1, aes(x = Rank, y = value, fill = variable)) +
  geom_bar(stat = "identity")


Hey @kurt,

This is due to the changes in Plotly 4.0. You can make a few changes to the code and manually set hoverinfo:

p <- ggplot(DF1, aes(x = Rank, y = value, fill = variable, text = paste("Value:", value))) +
  geom_bar(stat = "identity")

ggplotly(p, tooltip = "text")

This ought to be closer to what you’re looking for.


Thanks, that works!
The default behavior (showing a cumsum from the top of the bar) feels unintuitive and I can’t envision many cases where a user would expect or want this, so you(?) might consider changing it. At the very least, would be really helpful to update the example.