Stackgroup with scatter and more than 1 axis not working properly?
まだ誰も着手していません。
- 主要言語
- R
- スター
- 2.7k
- フォーク
- 641
- PR マージ指標
- 30日以内にマージされた PR はありません
説明
I am doing a scatter plot with stackgroups. I would like to use the x2 and y2 axises. When I use the regular x and y axis, the result is correct. The data frame below is used. The first Plotly chunk is for the regular x and y axis behavior. The second one tries to use x2 and y2 but only the 2nd stack group is shown. I think this might be a bug.
library(datasets)
df <- mtcars[1:5,]
df$mpg <- 0
df$qsec <- df$qsec + runif(length(df$qsec),min=-3, max=5)
df$hp <- df$hp + runif(length(df$hp),min=-30, max=30)
df$names <- rownames(df)
rownames(df) <- NULL
df2 <- mtcars[1:5,]
df2$names <- rownames(df2)
rownames(df2) <- NULL
df<- rbind(df,df2)
Below works but since the y axis range is quite different for qsec and hp, a second y axis is needed.
library(dplyr)
library(plotly)
plot_ly(type = "scatter",mode='none', width = 800, height=420) %>%
add_trace(
mode = "lines",
stackgroup = "red",
orientation = "h",
x = df$mpg,
y = df$qsec,
line = list(color = "red"),
name = df$names) %>%
add_trace(
mode = "lines",
stackgroup = "blue",
orientation = "h",
x = df$mpg,
y = df$hp,
line = list(color = "blue"),
name = df$names)%>%
layout( xaxis =list(title="mpg", side = "bottom"),
yaxis =list(title="qsec",side = "left"))
Here, the following is tried.
library(dplyr)
library(plotly)
plot_ly(type = "scatter",mode='none', width = 800, height=420) %>%
add_trace(
mode = "lines",
stackgroup = "red",
orientation = "h",
x = df$mpg,
y = df$qsec,
line = list(color = "red"),
name = df$names) %>%
add_trace(
mode = "lines",
stackgroup = "blue",
orientation = "h",
xaxis = "x2",
yaxis = "y2",
x = df$mpg,
y = df$hp,
line = list(color = "blue"),
name = df$names)%>%
layout( xaxis =list(title="mpg", side = "bottom"),
yaxis =list(title="qsec",side = "left")
,yaxis2 = list(title = "hp", side = "right", overlaying = "y")
,xaxis2 = list(title = "mpg", side = "top", overlaying = "y")
)
I also tried using fill = "tozerox" and fill = "tozeroy" instead of orientation="h"|"v" but this doesn't work at all. Thank you in advance for taking a look. :-)
コントリビューションガイド
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
調査の方向性
まず、提供されている2つのR例を実行し、2つ目のtraceがstackgroupとともに xaxis = "x2" および yaxis = "y2" を使用した場合の出力を比較します。複数の軸にまたがる積み上げscatter traceをadd_traceとlayoutがどのように処理するかを追跡します。両方のstack groupが第2軸で正しくレンダリングされるか、サポートされている制限が文書化された時点でissueは完了です。
索引モデルが issue の本文から書いたものです。
評価
- 技術スタック
- plotly, r
- 領域
- data-visualization
- issue の種類
- バグ
- 難易度
- 4/5
- 見積もり時間
- 3〜5日
- 活発さ
- 停滞
- 明瞭さ
- おおむね明確
- 初心者へのやさしさ
- 35/100