ggplotly() unable to fit 4 plots in 3 columns using a "ggplot() + facet_wrap()" object
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,
It turns out that ggplotly() is unable to fit 4 plots in 3columns when the ggplot object to be converted was designed using this structure ggplot(df, aes(x,y) + facet_wrap(~ var, ncol = 3). It does not matter which example you use.
Let's use this example from the plotly community website, see section "labels":
https://plotly.com/ggplot2/facet_wrap/#labels
df <- diamonds[sample(1:nrow(diamonds), size = 1000), ]
# Create labels
labs <- c("Best","Second best","Third best","Average", "Average","Third Worst","Second Worst","Worst")
levels(df$clarity) <- rev(labs)
# filter variable "clarity" to get 4 plots in the facet
df <- df %>%
filter(clarity %in% c("Worst", "Average", "Third best", "Best"))
p <- ggplot(df, aes(carat, price)) +
geom_point() +
facet_wrap(~ clarity, ncol = 3) # make clear that 3 columns are needed
fig <- ggplotly(p)
fig
I will attach the outputs so you can see the bug:




It is easy tu bypass this issue, just changing the number of columns. Nevertheless, it would be great if this didn't happen.
Kind regards,
Sergi
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
Tái hiện vấn đề với ví dụ diamonds từ trang «facet_wrap labels» của Plotly, sử dụng ggplot() với facet_wrap(~ clarity, ncol = 3) và chuyển đổi nó bằng ggplotly(). Kiểm tra quá trình chuyển đổi facet_wrap và so sánh kết quả được render với ggplot ban đầu. Hoàn thành khi bốn biểu đồ vừa khớp chính xác trong ba cột ở hình đã chuyển đổi.
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