Bug report – colour-mapped markers on a date x-axis reset axis to 1970
Nessuno ha ancora preso questa issue.
- Lingua principale
- R
- Stelle
- 2.7k
- Fork
- 641
- Metriche di merge delle PR
- Nessuna PR unita negli ultimi 30g
Descrizione
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)
Guida per i contributori
Apri la guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Direzione di ricerca
Inizia eseguendo il R reprex fornito con plotly 4.10.4 e confronta la mappatura delle dimensioni funzionante con la mappatura di colour che non funziona. Traccia come vengono preparati i marker mappati su colour e i valori Date di x; il lavoro è completato quando l’asse x rimane tra 2022-01-01 e 2022-07-20 usando colour = ~rank.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Valutazione
- Stack tecnologico
- r
- Ambito
- data-visualization
- Tipo di issue
- Bug
- Difficoltà
- 3/5
- Tempo stimato
- 1-2 giorni
- Stato di attività
- Ferma
- Chiarezza
- Abbastanza chiara
- Idoneità per principianti
- 45/100