Stackgroup with scatter and more than 1 axis not working properly?
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ả
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. :-)
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 hai ví dụ R được cung cấp và so sánh đầu ra khi trace thứ hai sử dụng xaxis = "x2" và yaxis = "y2" với stackgroup. Theo dõi cách add_trace và layout xử lý các scatter trace xếp chồng trên nhiều trục; issue được hoàn tất khi cả hai nhóm xếp chồng đều được render chính xác với các trục phụ, hoặc khi giới hạn được hỗ trợ được ghi lại.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Đánh giá
- Công nghệ
- plotly, 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
- 35/100