hovermode='x unified' is causing unexpected behavior together with group_by()
Nobody has claimed this yet.
- Dominant language
- R
- Stars
- 2.7k
- Forks
- 641
- PR merge metrics
- No merged PRs in 30d
Description
library(tidyverse)
library(plotly)
TexasCities_plus_Houston <- ggplot2::txhousing %>%
group_by(city) %>%
plot_ly(x = ~date, y = ~median) %>%
add_lines(
name = "Texan Cities",
text = ~paste0(city, "\n", median),
hoverinfo = "text+x"
) %>%
filter(city == "Houston") %>%
add_lines(name = "Houston")
This works as expected (but the limitation is that it is hard to find Houston city to hover on):
TexasCities_plus_Houston %>% layout(hovermode = "closest")
This solves the above limitation, however, it does not matter which point you hover on, the same city name is shown ("Wichita Falls"). The "median" variable changes as expected, the problem seems to be solely with the variable used in group_by(), in this case, "city".
TexasCities_plus_Houston %>% layout(hovermode = "x unified")
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by running the supplied R reproducer with plot_ly(), group_by(city), add_lines(), and layout(hovermode = "x unified"). Compare the unified hover labels with hovermode = "closest" and trace how the grouped city value is selected; done means the unified hover shows the city belonging to the hovered point while preserving the changing median.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- r
- Domain
- data-visualization
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100