When I use plotly in R to plot a bar chart which has highlighting function by clicking, only half of the bar is highlighted, as can be reproduced by the following script.
library(plotly)
D = data.frame(
NAME = LETTERS[1:5],
VALUE = rnorm(5)
)
D %>%
highlight_key(~NAME) %>%
plot_ly(x=~VALUE, y = ~NAME, type ="bar", orientation = "h") %>%
highlight(on = "plotly_click",off = "plotly_doubleclick")
What I can see in my Rstudio:

You can solve the issue by added layout(barmode = "overlay").
library(plotly)
D = data.frame(
NAME = LETTERS[1:5],
VALUE = rnorm(5)
)
D %>%
highlight_key(~NAME) %>%
plot_ly(x=~VALUE, y = ~NAME, type ="bar", orientation = "h") %>%
highlight(on = "plotly_click",off = "plotly_doubleclick") %>%
layout(barmode = "overlay")

Alternatively it is possible to use selectedpoints in plot_ly function.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With