frame in `ggplotly` not working when taking a `Date` object
Open
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
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 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