Reputation: 6314
I'm using R
plotly
to plot a horizontal bar chart with 'hoverinfo', and the 'hoverinfo' is plotted rather than appearing when being hovered over:
library(dplyr)
library(plotly)
set.seed(1)
df <- data.frame(x = runif(5,-10,10), y = paste0("label:", 1:5), text = paste0("text\n",paste0("label:", 1:5)))
df$y <- factor(df$y, levels = df$y)
plotly::plot_ly(data = df, x =~ x,y =~ y, type = 'bar', text =~ text, hoverinfo = "text",orientation = 'h') %>%
plotly::layout(xaxis = list(zeroline = F), yaxis = list(zeroline = F))
This seems unique to plotly
's bar
type
because it doesn't happen with other type
's. For example, plotting these data as a scatter plot doesn't not have that issue:
plotly::plot_ly(data = df, x =~ x,y =~ y, text =~ text, hoverinfo = "text", type = 'scatter',mode = "markers") %>%
plotly::layout(xaxis = list(zeroline = F), yaxis = list(zeroline = F))
Any idea how to fix the problem in the bar
type
?
Upvotes: 0
Views: 15