plotly / plotly/plotly.R

Markers are not alligned with bars when a double horizontal axis is used

Đang mở
#1,875 0 bình luận 0 reaction 0 người được giao Xem trên GitHub

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ả

Plotly behaves strangely when two sets of data are superimposed, and there is a double horizontal axis.
Bars overlayed on bars give no issue: see the following reprex.

library(plotly)
#> Loading required package: ggplot2
#> 
#> Attaching package: 'plotly'
#> The following object is masked from 'package:ggplot2':
#> 
#>     last_plot
#> The following object is masked from 'package:stats':
#> 
#>     filter
#> The following object is masked from 'package:graphics':
#> 
#>     layout

plot_ly() %>%
  add_trace(x = ~1:31,
            y = ~1:31,
            name = 'blue data',
            type = 'bar') %>% 
  add_trace(x = ~101:131,
            y = ~31:1,
            opacity = 0.7,
            name = 'orange data',
            type = 'bar',
            xaxis = 'x2') %>% 
  layout(xaxis = list(title = ''),
         xaxis2 = list(
           overlaying = "x",                                        
           side = "top")
  )
#> Warning: `arrange_()` is deprecated as of dplyr 0.7.0.
#> Please use `arrange()` instead.
#> See vignette('programming') for more help
#> This warning is displayed once every 8 hours.
#> Call `lifecycle::last_warnings()` to see where this warning was generated.

image

Created on 2020-10-29 by the reprex package (v0.3.0)

Now look at what happens if I replace the orange bars with orange markers: the second x axis on the top is squeezed between the second and the second to last bar, messing up the visualization.

library(plotly)
#> Loading required package: ggplot2
#> 
#> Attaching package: 'plotly'
#> The following object is masked from 'package:ggplot2':
#> 
#>     last_plot
#> The following object is masked from 'package:stats':
#> 
#>     filter
#> The following object is masked from 'package:graphics':
#> 
#>     layout

plot_ly() %>%
  add_trace(x = ~1:31,
            y = ~1:31,
            name = 'blue data',
            type = 'bar') %>% 
  add_trace(x = ~101:131,
            y = ~31:1,
            opacity = 0.7,
            name = 'orange data',
            type = 'scatter',
            mode = 'markers',
            xaxis = 'x2') %>% 
  layout(xaxis = list(title = ''),
         xaxis2 = list(
           overlaying = "x",                                        
           side = "top")
  )
#> Warning: `arrange_()` is deprecated as of dplyr 0.7.0.
#> Please use `arrange()` instead.
#> See vignette('programming') for more help
#> This warning is displayed once every 8 hours.
#> Call `lifecycle::last_warnings()` to see where this warning was generated.

image

Created on 2020-10-29 by the reprex package (v0.3.0)

Hướng dẫn đóng góp

Mở hướng dẫn đóng góp

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. 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.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. 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ụ plot_ly() với add_trace() và layout(), so sánh trường hợp thanh và marker. Theo dõi cách các điểm đầu vào vẽ biểu đồ của R xử lý các cấu hình xaxis và xaxis2 chồng lớp; được xem là hoàn tất khi marker sử dụng cùng căn chỉnh ngang như các thanh mà không làm ép trục phía trên.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Đánh giá

Công nghệ
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

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.