plotly / plotly/plotly.R

Categoryorder not working when specifying plot type

Đang mở
#2,082 0 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ả

When using the category order parameter, no plot is generated if the plot type is specified in the plot_ly call:

p <- plotly::plot_ly(type = 'bar')
colNames <- names(iris)
colNames <- colNames[-which(colNames == 'Species')]

for(trace in colNames){
  p <- p %>% plotly::add_trace(data= iris, x = ~ Species, y = as.formula(paste0("~`", trace, "`")), name = trace)
}

p  %>% layout(xaxis = list(categoryorder='total descending'))

With the following warning, which I don't understand since I'm not combining discrete and non-discrete data in the same axis:

Warning message:
Can't display both discrete & non-discrete data on same axis 

If I specify the type in add_trace instead of the plot, then it works correctly and the warning is gone:

p <- plotly::plot_ly()
colNames <- names(df)
colNames <- colNames[-which(colNames == 'Species')]

for(trace in colNames){
  p <- p %>% plotly::add_trace(type = 'bar', data= iris, x = ~ Species, y = as.formula(paste0("~`", trace, "`")), name = trace)
}

p %>% layout(xaxis = list(categoryorder='total descending'))

Maybe this is the intended behavior? If so, why does specifying the type in the traces works and not in the plot? The warning seems unclear to me.

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

Bắt đầu bằng cách chạy reproduction R được cung cấp với iris và so sánh plot_ly(type = 'bar') với add_trace(type = 'bar'). Truy vết cách plot_ly và add_trace truyền type như thế nào và cách layout(xaxis = list(categoryorder = 'total descending')) xử lý các trace kết quả. Hoàn tất nghĩa là reproduction không còn phát ra cảnh báo và việc sắp xếp category hoạt động nhất quán.

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
48/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.