Bar plot shows too many ticks
Nobody has claimed this yet.
- Dominant language
- R
- Stars
- 2.7k
- Forks
- 641
- PR merge metrics
- No merged PRs in 30d
Description
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"
)
)
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"
)
)
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"
)
)
Is this already somewhere addressed?
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
Start by running the single-observation R example with plot_ly() and the xaxis type and tickformat options, then compare it with the stacked-bar and unformatted examples. Trace how the date axis and tick formatting are handled; done means the single-date bar plot shows the expected tick without introducing extra formatted ticks, while the existing stacked behavior remains unchanged.
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
- 45/100