plotly / plotly/plotly.R

Bar plot shows too many ticks

未关闭
#2,421 1 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

还没有人认领这个 Issue。

主要语言
R
星标
2.7k
派生
641
PR 合并指标
30 天内没有已合并 PR

描述

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?

贡献指南

打开贡献指南

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

调研方向

首先运行使用 plot_ly() 以及 xaxis 类型和 tickformat 选项的单观测 R 示例,然后将其与堆叠柱状图和未格式化示例进行比较。跟踪日期轴和刻度格式的处理方式;完成的标准是,单日期柱状图显示预期的刻度,且不会引入额外的格式化刻度,同时现有的堆叠行为保持不变。

由索引模型根据 Issue 内容生成。

评估

技术栈
r
领域
data-visualization
Issue 类型
缺陷
难度
3/5
预计耗时
1-2 天
活跃度
停滞
描述清晰度
基本清楚
新手友好度
45/100

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。