Skip to content

Bar plot shows too many ticks #2421

Open
@emrichter

Description

@emrichter

In plotly 4.10.4 a bar plot with only one date observation shows actually multiple ticks when the ticks' format is converted. Here a minimal reproducible example:

library(dplyr)
library(plotly)

df <- tibble(Time = "2025-01", Animal = "Monkey", value = 2)

df %>%
  plot_ly(x = ~Time, y= ~value, color = ~Animal) %>%
  layout(
    xaxis = list(
      type = "date",
      tickformat = "%b '%y"
    )
  )

Image

This is not the case though for a stacked bar plot:

df <- tibble(Time = c("2025-01", "2025-01"), Animal = c("Monkey", "Lion"), value = c(2, 3))

df %>%
  plot_ly(x = ~Time, y= ~value, color = ~Animal) %>%
  layout(
    barmode = "stacked",
    xaxis = list(
      type = "date",
      tickformat = "%b '%y"
    )
  )

Image

When looking at the dates without formatting one can see a few minimal shifts around the actual date:

df <- tibble(Time = "2025-01", Animal = "Monkey", value = 2)

df %>%
  plot_ly(x = ~Time, y= ~value, color = ~Animal) %>%
  layout(
    xaxis = list(
      type = "date"
    )
  )

Image

Is this already somewhere addressed?

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