plotly / plotly/plotly.R

geom_text() re-renders every frame in animation if there are values outside of bounds

Open
#1,953 0 comments 0 reactions 0 assignees View on GitHub

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

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. 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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.