Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Remove hover info text from a plotly object

Tags:

r

hover

plotly

I'm creating a plotly object in R:

library(plotly)
p <- plot_ly(data = iris, x = ~Sepal.Length, y = ~Petal.Length, text = ~Species, hoverinfo="text",
             marker = list(size = 10,
                           color = 'rgba(255, 182, 193, .9)',
                           line = list(color = 'rgba(152, 0, 0, .8)',
                                       width = 2))) %>%
  layout(title = 'Styled Scatter',
         yaxis = list(zeroline = FALSE),
         xaxis = list(zeroline = FALSE))

As you can see it includes hoverino.

Then at some point I would like to remove that hoverinfo layer.

Any idea how to do that?

like image 615
dan Avatar asked Sep 13 '25 03:09

dan


1 Answers

style(hoverinfo = 'none')

So putting it all together:

(p <- plot_ly(data = iris, x = ~Sepal.Length, y = ~Petal.Length, text = ~Species, hoverinfo="text",
             marker = list(size = 10,
                           color = 'rgba(255, 182, 193, .9)',
                           line = list(color = 'rgba(152, 0, 0, .8)',
                                       width = 2))) %>%
  layout(title = 'Styled Scatter',
         yaxis = list(zeroline = FALSE),
         xaxis = list(zeroline = FALSE)) %>% 
  style(hoverinfo = 'none'))
like image 140
astrofunkswag Avatar answered Sep 15 '25 18:09

astrofunkswag