Skip to content

frame in ggplotly not working when taking a Date object #1005

@earowang

Description

@earowang

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

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions