plotly / plotly/plotly.R

Bug report – colour-mapped markers on a date x-axis reset axis to 1970

オープン
#2,446 コメント 2 件 リアクション 0 件 担当者 0 名 GitHub で見る

まだ誰も着手していません。

主要言語
R
スター
2.7k
フォーク
641
PR マージ指標
30日以内にマージされた PR はありません

説明

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)

コントリビューションガイド

コントリビューションガイドを開く

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

調査の方向性

まず、提供された R reprex を plotly 4.10.4 で実行し、動作するサイズマッピングと失敗する colour マッピングを比較します。colour にマッピングされたマーカーと Date の x 値がどのように準備されるかを追跡します。colour = ~rank を使用したときに x 軸が 2022-01-01 から 2022-07-20 の範囲内に留まれば完了です。

索引モデルが issue の本文から書いたものです。

評価

技術スタック
r
領域
data-visualization
issue の種類
バグ
難易度
3/5
見積もり時間
1〜2日
活発さ
停滞
明瞭さ
おおむね明確
初心者へのやさしさ
45/100

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。