plotly / plotly/plotly.R

Trace is lost with animation, not all ids exist in the legend

Open
#1,696 4 comments 3 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 couldn't find this issue here - copying it accordingly:

This issue arises when I have animated frames and the ids do not exist for all frames (particularly the first one). Here is a reproducible example:

dat = data.frame(f = rep(1:4, each = 10), 
             x = rep(1:5, 2*4), 
             y = rep(c(rep(1, 5), rep(2, 5)), 4), 
             id = rep(rep(LETTERS[1:2], each = 5), 4))
dat = dat[dat$id == "B" | dat$id == "A" & dat$f == 3,]
plot_ly(x = ~ x, 
    y = ~ y,colors = c("#FF0000","#0000FF")) %>%
  add_lines(
    data = group_by(dat, id, f),
    frame = ~ f,
    key = ~ id,
    ids = ~ id,
    color = ~ id)

Notice in frame 3 that the line at y = 2 disappears. I also get a warning:

Warning message:
In p$x$data[firstFrame] <- p$x$frames[[1]]$data :
number of items to replace is not a multiple of replacement length

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

Start by running the reproducible R example in the issue and inspect how animated frames, ids, and the first frame are assembled. Done means the line at y = 2 remains visible in frame 3 and the replacement-length warning no longer appears.

Written by the indexing model from the issue text.

Assessment

Tech stack
r
Domain
data-visualization
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 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.