`ggplotly` error on plot with `geom_contour` when one level of a factor isn't represented
オープン
まだ誰も着手していません。
- 主要言語
- R
- スター
- 2.7k
- フォーク
- 641
- PR マージ指標
- 30日以内にマージされた PR はありません
説明
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)
コントリビューションガイド
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
調査の方向性
まず、issue にある再現可能な R の例を実行し、欠落している因子レベルによって生成される zero-contour レイヤーを ggplotly がどのように処理するかを追跡します。プロットがデータフレーム置換エラーをスローしなくなり、情報量のある zero-contour 警告が維持されれば完了です。
索引モデルが issue の本文から書いたものです。
評価
- 技術スタック
- r
- 領域
- data-visualization
- issue の種類
- バグ
- 難易度
- 3/5
- 見積もり時間
- 1〜2日
- 活発さ
- 停滞
- 明瞭さ
- おおむね明確
- 初心者へのやさしさ
- 48/100