4

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?

1 Answer 1

4
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'))
Sign up to request clarification or add additional context in comments.

1 Comment

If you use ggplotly to generate the plot, you can edit hoverinfo doing p$data[[1]]$hoverinfo='none'. I am surprised to see plot_ly output has a different structure

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.