geom_text() re-renders every frame in animation if there are values outside of bounds
Open
Nobody has claimed this yet.
- Dominant language
- R
- Stars
- 2.7k
- Forks
- 641
- PR merge metrics
- No merged PRs in 30d
Description
I've found that when using animation in a ggplot object that has a limited view using scale_y_continuous(), only a (seemingly random) set of the visible text values rerender on every frame. Gif and reprex below.

text_data <- tibble::tribble(
~text,~x,~y,
"test1",1,1,
"test2",1,2,
"test3",2,1,
"test4",2,2
)
point_data <- tibble::tribble(
~x,~y,
1,1,
2,1,
3,1,
1,2,
2,2,
3,2
)
p <- ggplot() +
geom_text(aes(x = x,y = y,label = text),data = text_data) +
geom_jitter(aes(x = x,y = y,frame = x,color = y),data = point_data) +
scale_y_continuous(limits = c(0,1.5)) #view limited to 1.5 and thus does not show the text_data observations in y position of 2
ggplotly(p) %>%
animation_opts(redraw = F,frame = 2000,transition = 2000)
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
Run the supplied R reprex with ggplotly and the limited scale_y_continuous() range to reproduce the animation behavior. Trace the ggplotly animation rendering path for geom_text values outside the bounds; done means visible text remains stable across frames instead of being re-rendered repeatedly.
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
- 45/100