plotly / plotly/plotly.R

ggplotly() is unable to merge legend entries across layers

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

Chưa có ai nhận issue này.

ggplotly
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ả

Thanks for an amazing package! The mapping between plotly and ggplot is particularly impressive and very powerful!

However, ggplotly fails to reproduce the appropriate legends generated by ggplot in non-trivial facet_wrap cases. After discussion on stackoverflow some of this behavior appears to be a bug.

Consider the following minimal reprex:

library(plotly)
library(ggplot2)

p <- mpg %>% 
  ggplot(aes(year)) +
  geom_ribbon(aes(ymin=cty, ymax=hwy, fill = manufacturer), alpha=0.2) + 
  geom_line(aes(y = hwy, col=manufacturer))  +
  facet_wrap(~class)
p
plotly::ggplotly(p)

Note that (a) we get too many plotly legend entries, duplicating the legend for each facet, due to legendgroup not being correctly handled. Also note (b) the legends we do and don't get depend on the order (do we do geom_ribbon first or geom_line first). The bug does not appear if we have only one geom, and the missing legends continue as we add more geoms.

Perhaps not related -- but the interactive zoom options in faceted plots are not entirely intuitive either, i.e. it's not possible to zoom the whole window on a single facet plot. (Perhaps the take home is that it might be better to render facet plots as more independent objects in plotly)?

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 với reprex tối thiểu của ggplotly() sử dụng geom_ribbon, geom_line và facet_wrap(~class), sau đó kiểm tra cách legendgroup được xử lý giữa các layer và facet. So sánh các chú giải đã chuyển đổi với các chú giải mong đợi của ggplot2; được xem là hoàn tất khi không có mục nào bị trùng hoặc thiếu, bất kể thứ tự của các geom, đồng thời vẫn giữ nguyên hành vi của facet.

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ó
4/5
Thời gian dự kiến
3-5 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
38/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.