plotly / plotly/plotly.R

ggplotly doesn't display geom_rect with ymin = -Inf and ymax = Inf

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

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

bug ggplotly
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ả

In ggplot::geom_rect(), one can specify the aesthetics ymin = -Inf and ymax = Inf, which will draw the rectangles to the limit of the plotting area. Apparently, ggplotly does not support this behaviour, and will fail to display the rectangles when a ggplot object with such a geom_rect is passed.

Motivation This behaviour of geom_rect is especially useful for indicating time periods of interest when plotting time series. Workarounds such as manually specifying the ymin and ymax limits to mimic the behaviour are much less effective: it can be difficult to know in advance what those limits should be, and they are affected by expand settings in the scale specification.

# Plot definition
example_plot = economics %>%
  ggplot() +
  geom_line(aes(x = date, y = psavert)) +
  geom_rect(data = data.frame(xmin = seq(as.Date('1970-01-01'),
                                         as.Date('2010-01-01'),
                                         '10 years'),
                              xmax = seq(as.Date('1975-01-01'),
                                         as.Date('2015-01-01'),
                                         '10 years'),
                              ymin = -Inf, ymax = Inf),
            aes(xmin = xmin, xmax = xmax, ymin = ymin, ymax = ymax))
# Base ggplot object
example_plot

image

# Calling ggplotly
example_plot %>% ggplotly()

image

Note ggplotly image above captured using 'export' function on Viewer pane in RStudio.

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 ví dụ economics và geom_rect được cung cấp qua ggplotly(), sau đó lần theo điểm vào của quá trình chuyển đổi ggplotly cho geom_rect. So sánh ggplot cơ sở với đầu ra được render; hoàn tất khi các hình chữ nhật có ymin = -Inf và ymax = Inf được hiển thị tới các giới hạn của vùng vẽ.

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

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.