Bug report – colour-mapped markers on a date x-axis reset axis to 1970
Chưa có ai nhận issue này.
- Ngôn ngữ chính
- R
- Star
- 2.7k
- Fork
- 641
- Chỉ số merge pull request
- Không có pull request nào được merge trong 30 ngày
Mô tả
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)
Hướng dẫn đóng góp
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Hướng nghiên cứu
Bắt đầu bằng cách chạy R reprex được cung cấp với plotly 4.10.4 và so sánh ánh xạ kích thước đang hoạt động với ánh xạ colour bị lỗi. Theo dõi cách các marker được ánh xạ theo colour và các giá trị Date của x được chuẩn bị; được xem là hoàn tất khi trục x vẫn nằm trong khoảng từ 2022-01-01 đến 2022-07-20 khi sử dụng colour = ~rank.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Đánh giá
- Công nghệ
- r
- Lĩnh vực
- data-visualization
- Loại issue
- Lỗi
- Độ khó
- 3/5
- Thời gian dự kiến
- 1-2 ngày
- Mức độ hoạt động
- Đình trệ
- Độ rõ ràng
- Khá rõ ràng
- Mức phù hợp với người mới
- 45/100