Skip to content

ggplotly()'s colorbar trace can override hover behavior #1381

Closed
@cpsievert

Description

@cpsievert

Thanks to @goodekat for the reprex

library(plotly)
library(tidyr)

m <- matrix(rnorm(9), nrow = 3, ncol = 3)

m_gathered <- data.frame(m) %>%
  gather(key = column) %>%
  mutate(row = factor(rep(c("X1", "X2", "X3"), 3))) %>%
  select(column, row, value)

p <- ggplot(m_gathered, aes(x = column, y = row, fill = value)) +
  geom_tile()

# Apply plotly to ggplot heatmap - deadspace in the middle of (X1, X1)
ggplotly(p)

hover

The fix seems easy -- change hoverinfo="none" to hoverinfo="skip" when creating the colorbar trace

https://github.com/ropensci/plotly/blob/7031a25474f0dc275d20897810682c530cd1fbf3/R/ggplotly.R#L1303

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions