Skip to content

dynamicTicks changes dateLabels #1184

@bartverweire

Description

@bartverweire

Using dynamicTicks on a plotly object obtained using ggplotly, changes the date labels.
I created a ggplot object, and set the date_labels to "%m/%y".
The ggplotly output changes this date format to "%b %Y"

library(ggplot2)
library(plotly)

x <- seq(as.POSIXct(Sys.Date()), as.POSIXct(Sys.Date() + 365) , by = "months")
y <- seq(1:length(x))
df <- data.frame(x, y)

(p <- ggplot(df, aes(x, y)) +
    geom_point() +
    scale_x_datetime(date_breaks = "1 month", date_labels = "%m/%y") +
    theme(axis.text.x = element_text(angle = 90)))

ggplotly(p, dynamicTicks = TRUE) %>%
  layout(margin = list(b = 70))

The ggplot output :
ggplot

The ggplotly output :
ggplotly

Removing the dynamicTicks property leaves the x-axis labels unchanged.

ggplotly2

This looks like the issue #860, which is already closed.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions