Hi ,
Using the following data i cannot get the hover function to work (the stacked bar is created but the hover function does not display the text).
I have noticed that if i remove the “color=~variable” statement then it works but i don´t get the colors displayed by variable
Now if i remove the statement “color=~variable” and create an new graph below then hover is only working for one value and there is no coloring by variable.
Simplifying your code highlights the issue is with your text. Here are some examples of using text https://plot.ly/r/text-and-annotations/. The following is simplified which produces your desired hover outcome:
Sample <- c('Sample01', "Sample01", "Sample01")
variable <- c("staph", "Mala", "Unknown")
value <- c(79.08, 15.83, 1.74)
mm <- data.frame(Sample, variable, value)
plot_ly(mm, x = ~Sample, y = ~value, color = ~variable, type = "bar") %>%
layout(bargap=0.9, barmode = 'stack')
Hi bcd,
Your example works but the text cannot be modified and this is important since my text is customized.
I have modified your example by adding the custom text and it does not display the text (as in the first graph). Seems to be something related to text ?? Any idea ??