geom_sina plot doesn't show when linked to another plot via brushing in Shiny
オープン
まだ誰も着手していません。
- 主要言語
- R
- スター
- 2.7k
- フォーク
- 641
- PR マージ指標
- 30日以内にマージされた PR はありません
説明
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)
コントリビューションガイド
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
調査の方向性
まず、提供された R Shiny の例を実行し、ggforce::geom_sina のケースと動作する geom_point のケースを比較します。ggplotly への変換と key の処理を追跡して、key=key を追加するとプロットがレンダリングされなくなる理由を特定します。sina プロットが表示され、クリックした点が引き続き 2 番目のプロットにリンクされれば完了です。
索引モデルが issue の本文から書いたものです。
評価
- 技術スタック
- r
- 領域
- data-visualization
- issue の種類
- バグ
- 難易度
- 4/5
- 見積もり時間
- 3〜5日
- 活発さ
- 停滞
- 明瞭さ
- おおむね明確
- 初心者へのやさしさ
- 45/100