I am trying to make a very simple bar chart with ggplot2 and then to turn it into interactive graph with the ggplotly function from the plotly package. The final graph looks ok, but the values rendered in the hover text are not good. Actually, it renders stacked values instead of individual values.
Here is a reproducible example :
#data
dataf = data.frame(Espece = c("A","A","B","B","C","C"),
Type = c("A","B","A","B","A","B"),
Value = c(2,2,5,1,6,0))
#ggplot
gg = ggplot(dataf, aes(x = Espece, y = Value, fill = Type)) +
geom_bar(stat = "identity") +
theme(legend.position = "none") +
theme(axis.text.x = element_text(angle = 90, hjust = 1))
#plotly
p <- ggplotly(gg)
p
As you can see on the picture, the value for Espece A, type B is 4 whereas it should be 2.
Do you have any idea how I can fix this ?


dataf2in ggplot while creatingdatafjust before. Isdataf2a new data frame or equal todataf? Indataf, the value for Espece A, type B is 4. - bVa