plotly / plotly/plotly.R

Issue when specifying both the size and color mapping in a scatter plots

オープン
#1,744 コメント 2 件 リアクション 3 件 担当者 0 名 GitHub で見る

まだ誰も着手していません。

主要言語
R
スター
2.7k
フォーク
641
PR マージ指標
30日以内にマージされた PR はありません

説明

Hi,

I can not manage to specify both the size and the color mapping with completely satisfactory results.

If I specify the size mapping globally:

library(plotly)
df <- data.frame(x = 1:12, y = 1:12, s = 1:12, g = rep(c("A", "B", "C"), 4))

plot_ly(data = df, x = ~x, y = ~y, size = ~s, color= ~g)%>% 
  add_markers()

I have a perfect plot but I suffer from the spurious line.width warning already mentioned in https://github.com/ropensci/plotly/issues/1367

If I specify the size mapping in the marker itself:

plot_ly(data = df, x = ~x, y = ~y, color= ~g)%>% 
  add_markers(marker = list(size = ~s))

The sizes are wrong: it seems there is an ordering by group within plotly which is not used in the markers.

Indeed, sorting the data.frame according to the colors fixes the issue:

df_sorted = df[order(df[['g']]), ]
plot_ly(data = df_sorted, x = ~x, y = ~y, color= ~g)%>% 
  add_markers(marker = list(size = ~s))

Let me know how I can help!

コントリビューションガイド

コントリビューションガイドを開く

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

調査の方向性

plot_ly() と add_markers() を使用する2つの未ソートの例から始め、次に、それらのマーカーサイズの挙動をソート済みの data.frame の例と比較します。色によるグループ化とマーカーサイズのマッピングがどのように対応付けられているかを追跡し、未ソートのデータが報告された line.width 警告なしに意図したサイズを保持することを確認します。

索引モデルが issue の本文から書いたものです。

評価

技術スタック
r
領域
data-visualization
issue の種類
バグ
難易度
4/5
見積もり時間
3〜5日
活発さ
停滞
明瞭さ
おおむね明確
初心者へのやさしさ
35/100

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。