plotly / plotly/plotly.R

Sankey diagram: position of node cannot be rendered correctly

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

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

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

説明

Hello people!
I am trying to make a sankey diagram with Plotly, however, the alignment of certain node cannot be rendered correctly as I set.
PS: my Plotly version is 4.10.3 and R version is 4.3.1

Here is my code:

library("plotly")

# My data base
values <- c(10,1811,530,363,271,601,681,37,46,18,109,39,3,22,74,22,10,
            14,3,81,0,1,19,1807,521,363,270,601,16,36,8,46,86,1,0,0,23,
            14,18,34,684,23,0,16,0,23,0,0,0,23,14,18,69,1,34,0,0,0,684,
            43,643,101,6,68,43,620,101,6,19,1807,521,363,270,601,16,36,
            8,46,15,1555,79,244,346,4,115,2,2,0,4,17,251,265,1,3,25,3,
            16,0,8,43,105,24,2,1,1,6,0,601,0,129,196,109,14,82,124,1,
            34,2,0,13,0,11)
target <- c(2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,3,3,3,3,3,4,4,4,4,4,4,4,4,
            4,4,5,5,5,5,5,5,5,5,5,5,5,10,10,10,10,10,10,10,10,11,11,11,
            11,11,11,11,11,6,6,6,6,7,8,8,8,8,8,8,8,8,8,8,8,8,8,8,13,13,13,
            13,13,13,13,13,13,13,14,14,14,14,14,14,14,14,14,14,14,14,15,15,
            15,15,15,15,15,15,16,16,16,16,16,16,16,16,16,16,9,9,9,9)
source <- c(0,0,0,0,0,0,0,0,0,1,1,1,1,1,1,1,1,2,2,2,2,2,2,2,2,2,2,2,2,2,
            2,2,2,2,2,2,2,2,2,2,2,6,6,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,10,
            11,11,11,6,6,6,6,6,4,4,4,4,4,4,4,4,4,4,8,8,8,8,8,8,8,8,8,8,
            8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8)

num_node <- c(0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16)
x_position <- c(0.05,0.05,0.2,0.35,0.35,0.35,0.65,0.8,0.8,0.9,0.45,0.45,0.45,0.999,0.999,0.999,0.999)
y_position <- c(0.45,0.6,0.55,0.15,0.45,0.6,0.75,0.85,0.55,0.99,0.6,0.6,0.6,0.3,0.3,0.3,0.3)

# Sankey diagram with Plotly
fig <- plot_ly(
  type = "sankey",
  arrangement = "snap",
  node = list(
    label = num_node,
    x = x_position,
    y = y_position,
    pad = 15,
    thickness = 15
  ),
  link = list(
    source = source,
    target = target,
    value =  values
  )
)

fig

What I would expect is that node 13, 14, 15, 16 be at the same colomn, as I set their x position to 0.999. See picture below:
Capture d’écran 2024-01-11 à 18 38 34

However, for some reason, my node 13 would like to be in the middle of my diagram instead of the position where it should have been. See picture below:
Capture d’écran 2024-01-11 à 18 41 16

Does anyone have some insights why the node cannot accept x and y position I set? Thank you guys very much!

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

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

はじめの一歩

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

調査の方向性

Issue にある再現可能な R コードから始め、Plotly 4.10.3 を使用して実行し、Sankey arrangement="snap" が指定された x および y の位置をどのように処理するかを確認します。ノード 13–16 の Sankey の描画動作を調査し、その後、ノード 13、14、15、16 が x=0.999 の同じ列に留まることを確認します。

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

評価

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

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

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