plotly / plotly/plotly.R

geom_xspline not implemented in plotly - getting error message when using ggplotly() function

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

I get an error message when trying to implement geom_xspline with
plotly.

I get the desired graph in ggplot2 but the plot cannot be converted to a
plotly object when using the ggplotly function.
You can find the code showcasing this below.

library(pacman)
pacman::p_load(tidyverse, datasets, plotly, ggplotly, ggalt)
# airmiles built-in dataset: 
airmiles <- datasets::airmiles
year <- 1937:1960
airmiles <- data.frame(year = year, airmiles = airmiles)


# "line" plot using geom_xspline from ggalt package: 
plot_airmiles <- ggplot(data = airmiles, 
              aes(x = year, y = airmiles)) + 
  geom_point(alpha = 0.75) + 
  geom_xspline(spline_shape = -0.7) +
  scale_y_continuous(n.breaks = 10) 

plot_airmiles

Image

# interactive plot: using ggplotly doesn't work
ggplotly(plot_airmiles)

Image

Could this be implemented in plotly? Is there any way I can still
produce the interactive graph in plotly without waiting for this to be
implemented?

The plotly documentation (https://linking.plotly-r.com/custom-geoms)
mentions the possibility of creating custom geoms and using the
to_basic() function from the plotly package to “convert” the custom geom
into a geom plotly understands.
In the link above, the authors provide an example for geom_xspline
specifically but their method and code don’t work unfortunately.

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 lỗi bằng ví dụ airmiles được cung cấp, geom_xspline và ggplotly(). Đọc tài liệu về custom-geoms được liên kết trong issue, sau đó kiểm tra cách tiếp cận to_basic() được mô tả ở đó. Công việc được xem là hoàn tất khi geom_xspline có thể được chuyển đổi thành một đối tượng plotly, hoặc khi giới hạn được hỗ trợ và workaround được ghi lạ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ó
5/5
Thời gian dự kiến
Hơn một tuần
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
25/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.