geom_sina plot doesn't show when linked to another plot via brushing in Shiny
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ả
Hello,
I'm attempting to link points from a geom_sina object to another plot (it will be a bar-plot but for now, I just have a scatterplot to illustrate the problem). The issue is that when I put the "key=key" aesthetic into geom_sina, the plot doesn't show up.The plot will show up if I remove the "key=key" aesthetic, but then I have no means by which to connect the plots. I think this might be a bug given that this works fine with geom_point.
library(plotly)
library(shiny)
library(tidyverse)
df = diamonds
df = df[sample(1:nrow(df), size=1000, replace=FALSE), ] %>%
rownames_to_column("key")
server <- function(input, output) {
output$my_points <- renderPlotly({
p = ggplot(df, aes(x=cut, y=price, label=clarity)) +
coord_flip() +
ggforce::geom_sina(aes(color=carat, key=key), alpha=.2) +
# gggforce::geom_sina(aes(color=carat), alpha=.2) + # this will make the plot show up, but doesn't link it to the other
# geom_point(aes(color=carat, key=key), alpha=.2) + # using geom_point works here
theme_light()
ggplotly(p, source="ggplotly_points")
})
selected_values <- reactive({
brush <- event_data("plotly_click", source="ggplotly_points")
if (is.null(brush)) {
TRUE
} else {
df$key == (brush$pointNumber + 1)
}
})
output$scatter <- renderPlotly({
df %>%
filter(selected_values()) %>%
plot_ly(
x = ~carat,
y = ~price,
alpha = 0.2
) %>%
toWebGL()
})
}
ui <- fluidPage(
plotlyOutput("my_points"),
plotlyOutput("scatter")
)
shinyApp(ui, server)
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
Bắt đầu bằng cách chạy ví dụ R Shiny được cung cấp và so sánh trường hợp ggforce::geom_sina với trường hợp geom_point đang hoạt động. Theo dõi quá trình chuyển đổi ggplotly và cách xử lý key để xác định tại sao việc thêm key=key khiến biểu đồ không được render; hoàn tất khi biểu đồ sina hiển thị và các điểm được nhấp vào của nó vẫn liên kết với biểu đồ thứ hai.
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
- 45/100