plotly / plotly/plotly.R

Aspect ratio with small multiples / subplots

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

Chưa có ai nhận issue này.

enhancement
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 would like to create small multiples with a fixed aspect ratio. However, there seems to be a but somewhere and only some plots retain the correct aspect ratio.
From what I gathered, setting a fixed aspect ratio with plotly is done as follows: layout(yaxis = list(scaleanchor = "x"))

Consider the follwing example:

df <- data_frame(
  x = rep(1:5,25),
  y = rep(1:5,25),
  g = sort(rep(1:25,5))
)

plots <- df %>%
  split(.$g) %>%
  map(function(x){
    plot_ly(data = x, x = ~x, y = ~y, type = "scatter",mode = "lines") %>% add_lines()
  })

small_mulitples <- subplot(plots,nrows = 5) %>%
  layout(yaxis = list(scaleanchor  = "x")) %>%
  hide_legend()

If I plot small_mulitples, only the first plot (row 1, column 1) has an aspect ratio of 1. The other have an arbitrary aspect ratio.
small_multiples

Here's the link to the interactive version of this plot: https://plot.ly/~rata_zhaw/1/

Interestingly, if I choose the option shareX = T in subplot(), the entire first column has the correct aspect ratio. Nothing changes if I choose shareY = T

small_mulitples <- subplot(plots,nrows = 5, shareX = T) %>%
  layout(yaxis = list(scaleanchor  = "x")) %>%
  hide_legend()

small_multiples2

And here's the link to the interactive version of the second plot: https://plot.ly/~rata_zhaw/3/

If I plot any of the plots individually, the aspect ratio is correct:

plots[[10]] %>%
  layout(yaxis = list(scaleanchor  = "x")) %>%
  hide_legend()

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 tái hiện ví dụ R được cung cấp với subplot(), nrows = 5 và layout(yaxis = list(scaleanchor = "x")); so sánh với các trường hợp shareX = T và biểu đồ đơn. Theo dõi cách subplot() kết hợp các layout của biểu đồ, và coi issue là hoàn tất khi mọi small multiple vẫn giữ được tỷ lệ khung hình cố định mà không yêu cầu các trục dùng chung.

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
42/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.