animated ggplotly: geoms contesting visibility when plotted on same mappings
Nobody has claimed this yet.
- Dominant language
- R
- Stars
- 2.7k
- Forks
- 641
- PR merge metrics
- No merged PRs in 30d
Description
Cannot plot geom_point and geom_line on same mappings in animated ggplotly()
Creating a ggplot object (with frame) and calling in ggplotly(). I expect to be able to view geom_point and geom_text mapped to the variables. I sometimes observe one being displayed on more frames while the other flys in from the top left in one or few frames.
work around: add sub-pixel changes to one or both geoms till working.
library(ggplot2)
library(plotly)
rn <- data.frame(rn = 1:5)
x <- data.frame(scale(mtcars), lab=abbreviate(rownames(mtcars),2))
x_cross <- merge(x, rn, all = TRUE) # cross join
# Only text or points show, not both
gg1 <- ggplot() +
geom_text(data=x_cross, mapping = aes(x=disp, y=hp, label=lab, frame=rn)) +
geom_point(data=x_cross, mapping = aes(x=disp, y=hp, frame=rn),color="red") +
theme_void()
gg1
ggplotly(gg1)
# Text and points show for all frames
gg2 <- ggplot() +
geom_text(data=x_cross, mapping = aes(x=disp+.1*rn, y=hp, label=lab, frame=rn)) +
geom_point(data=x_cross, mapping = aes(x=disp+.1*rn, y=hp, frame=rn),color="red") +
theme_void()
gg2
ggplotly(gg2)
# tooltip = "none", changes behaviour, points don't show up.
ggplotly(gg2, tooltip = "none")
Cheers,
Nick
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 reproduction with ggplotly(), comparing animated geom_text and geom_point across frames and with tooltip = "none". Trace the animated ggplotly conversion and rendering path; done means both geoms remain visible on every frame without sub-pixel coordinate changes, while the reported tooltip behavior is understood or corrected.
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