plotly / plotly/plotly.R

frame in `ggplotly` not working when taking a `Date` object

Open
#1,005 0 comments 2 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

bug ggplotly
Dominant language
R
Stars
2.7k
Forks
641
PR merge metrics
No merged PRs in 30d

Description

Hi Carson,

The new animation feature is awesome. But I run into an issue when the frame arg takes a Date object, and I need to convert to numerics. Please see the little reproducible example below:

library(plotly)
df <- data.frame(
  Date = seq(as.Date("2017-01-01"), as.Date("2017-01-05"), by = 1),
  Hour = rep(1:24, 5),
  Value = rnorm(24 * 5)
)
p1 <- ggplot(aes(Hour, Value, frame = Date), data = df) +
  geom_line() # not working
ggplotly(p1)
p2 <- ggplot(aes(Hour, Value, frame = as.numeric(Date)), data = df) +
  geom_line() # working
ggplotly(p2)

Thanks a lot,
Earo

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 reproducible R example from the issue and compare ggplotly(p1), where frame uses Date, with ggplotly(p2), where it uses as.numeric(Date). Start at ggplotly's handling of the frame aesthetic and trace how Date values are converted. Done means a Date-valued frame works without manual numeric conversion and the existing numeric case remains working.

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
42/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.