Hacktoberfest 2026: những issue maintainer đã đánh dấu cho tháng Mười, đang mở và phù hợp người mới. Xem issue Hacktoberfest

`ggplotly` error on plot with `geom_contour` when one level of a factor isn't represented

Đang mở
#2,205 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.

Đánh giá

Độ khó
3/5
Thời gian dự kiến
1-2 ngày
Mức phù hợp với người mới
48/100
Loại issue
Lỗi
Độ rõ ràng
Khá rõ ràng
Mức độ hoạt động
Đình trệ
Công nghệ
r
Lĩnh vực
data-visualization

Hướng nghiên cứu

Bắt đầu bằng cách chạy ví dụ R có thể tái hiện trong issue và theo dõi cách ggplotly xử lý layer zero-contour được tạo ra bởi factor level bị thiếu. Được xem là hoàn tất khi plot không còn phát sinh lỗi thay thế data frame mà vẫn giữ lại các cảnh báo zero-contour mang tính thông tin.

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

Mô tả

Hi R Plotly Devs,
I hope this finds you well!
This issue involves a dataset with a factor where one factor level isn't represented.
When rendering a ggplot that plots a contour, ggplot will provide informative warnings that zero contours were drawn due to the missing factor level.
However, when this plot object is passed into ggplotly the following error is thrown:

Warning: stat_contour(): Zero contours were generated
Warning in min(x) : no non-missing arguments to min; returning Inf
Warning in max(x) : no non-missing arguments to max; returning -Inf
Error in `$<-.data.frame`(`*tmp*`, "fill", value = NA) : 
  replacement has 1 row, data has 0

I hope this is a relatively easy fix!

df <- tibble::tribble(
  ~response,        ~variable,      ~prediction,
  7.45549,          6.24703, "No",
  7.45549, 6.62491208333333, "No",
  7.45549, 7.00279416666667, "No",
  7.45549,       7.38067625, "No",
  7.45549, 7.75855833333333, "No",
  7.45549, 8.13644041666667, "No"
) |> 
  dplyr::mutate(prediction = factor(prediction, levels = c("Yes", "No")))
p = ggplot2::ggplot(data = df) +
  ggplot2::geom_point(data = df,
                      ggplot2::aes(
                        x = .data$response,
                        y = .data$variable,
                        color = prediction),
                      shape = 15,
                      size = 0.7,
                      alpha = 0.4) +
  ggplot2::geom_contour(data = df,
                        ggplot2::aes(x = .data$response,
                                     y = .data$variable,
                                     z = as.integer(prediction)),
                        color = "violet",
                        size = 0.5,
                        bins = 1)
plotly::ggplotly(p)
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

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.

Issue khác của plotly/plotly.R

Tất cả issue của plotly/plotly.R

Issue tương tự

Thêm issue về R

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.