Bug report – colour-mapped markers on a date x-axis reset axis to 1970
還沒有人認領這個 Issue。
評估
- 難度
- 3/5
- 預估耗時
- 1-2 天
- 新手友好度
- 45/100
- Issue 類型
- 缺陷
- 描述清晰度
- 基本清楚
- 活躍度
- 停滯
- 技術堆疊
- r
研究方向
首先使用 plotly 4.10.4 執行提供的 R reprex,並比較正常運作的大小映射與失敗的 colour 映射。追蹤 colour 映射標記和 Date x 值如何準備;使用 colour = ~rank 時,如果 x 軸維持在 2022-01-01 至 2022-07-20 範圍內,即表示完成。
由索引模型根據 Issue 內容生成。
描述
Hi
thank you for the great work on plotly for R. While building a simple time-series chart I noticed that mapping a numeric column to color inside a marker trace shifts the x-axis limits to the Unix epoch (1970-01-01). The same variable works fine when mapped to size. The reproducible examples below illustrate the behaviour. Any guidance or fix would be highly appreciated.
Reprex
library(plotly)
library(data.table)
# dummy data -------------------------------------------------------------
set.seed(1)
dt <- data.table(
y = cumsum(rnorm(200)),
rank = sample(1:100, 200, TRUE),
size_metric = rpois(200, 10),
datetime = seq(as.Date("2022-01-01"), by = "day", length.out = 200)
)
# -------- WORKS (no colour mapping) -------------------------------------
plot_ly(dt, type = "scatter", mode = "markers") |>
add_trace(x = ~datetime, y = ~y,
name = "points", size = ~size_metric) |>
add_trace(x = ~datetime, y = ~y,
name = "line", mode = "lines",
line = list(color = "black"))
# x-axis shows correct 2022-20xx window
# -------- WORKS (size mapped to same field) -----------------------------
plot_ly(dt, type = "scatter", mode = "markers") |>
add_trace(x = ~datetime, y = ~y,
name = "points", size = ~rank) |>
add_trace(x = ~datetime, y = ~y,
name = "line", mode = "lines",
line = list(color = "black"))
# ✓ still correct axis
# -------- FAILS (colour mapping) ----------------------------------------
plot_ly(dt, type = "scatter", mode = "markers") |>
add_trace(x = ~datetime, y = ~y,
name = "points", colour = ~rank) |>
add_trace(x = ~datetime, y = ~y,
name = "line", mode = "lines",
line = list(color = "black"))
# ✗ x-axis resets to 1970-01-01
Expected
Axis limits stay within the data’s date range (2022-01-01 … 2022-07-20).
Actual
When colour = ~rank is used, the x-axis jumps to epoch 1970-01-01.
Tested with
packageVersion("plotly") # 4.10.4
R.version.string # R 4.3.2 (MacOS Darwing)
- 主要語言
- R
- 星號
- 2.7k
- 分支
- 641
- PR 合併指標
- 30 天內沒有已合併 PR
環境準備
從這裡開始
- 先讀完整個 Issue,再讀專案的貢獻指南。
- 在 Issue 下留言說明你要接手 —— 這能避免兩個人做同樣的事。
- Fork 儲存庫,在一個分支上完成修改。
- 送出 Pull Request,並在描述裡引用這個 Issue 編號。
plotly/plotly.R 的其他 Issue
-
難度 2/5 1-3 小時 新手友好度 62/100
-
難度 4/5 3-5 天 新手友好度 35/100
-
難度 3/5 1-2 天 新手友好度 68/100
-
難度 3/5 1-2 天 新手友好度 72/100
-
save_image Error未關閉
難度 3/5 1-2 天 新手友好度 52/100
相似的 Issue
-
難度 2/5 1-3 小時 新手友好度 72/100
-
難度 1/5 1 小時以內 新手友好度 90/100
-
難度 2/5 1-3 小時 新手友好度 88/100
-
bug
難度 1/5 1 小時以內 新手友好度 95/100
tidymodels/textrecipes#332 ·