plotly / plotly/plotly.R

`colors` argument to `add_trace` is only respected if the trace type *isn't* specified in the `plot_ly` call

Đang mở
#2,474 1 bình luận 0 reaction 0 người được giao Xem trên GitHub

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ả

I'd expect these two lines of code to produce the same output, but only the first does what I expect (uses the colors argument to pick a palette for the points):

plot_ly(data = iris) %>%
  add_trace(x = ~Sepal.Length, y = ~Sepal.Width, color = ~Species, colors = "Blues", mode = "markers")
Image
plot_ly(data = iris, type="scatter") %>%
  add_trace(x = ~Sepal.Length, y = ~Sepal.Width, color = ~Species, colors = "Blues", mode = "markers")
Image

This seems backwards since I added the type="scatter" to avoid the warning about guessing the trace type, only to have my palette disappear.

Curiously, this behavior isn't present if everything is specified in the same call:

plot_ly(data = iris, x = ~Sepal.Length, y = ~Sepal.Width, color = ~Species, colors = "Blues")
plot_ly(data = iris, x = ~Sepal.Length, y = ~Sepal.Width, color = ~Species, colors = "Blues", type="scatter")

both return

Image

Is colors the correct way to pass a palette to a specific layer? In other places it seems like it's actually colorspace? I know scatter doesn't have a colors argument in schema() (e.g. #1699) but clearly it's working when the type is inferred and I would like to provide a palette...

Hướng dẫn đóng góp

Mở hướng dẫn đóng góp

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. 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.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Hướng nghiên cứu

Tái hiện hai ví dụ plot_ly/add_trace với iris và so sánh các bảng màu được tạo ra. Theo dõi việc xử lý màu qua các điểm vào plot_ly và add_trace, đặc biệt là đường dẫn type="scatter" tường minh. Được coi là hoàn tất khi cả hai dạng gọi đều xử lý colors="Blues" một cách nhất quán, với kiểm thử hồi quy cho các ví dụ khác nhau.

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

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.