Hacktoberfest 2026: die Issues, die Maintainer für den Oktober markiert haben – offen und einsteigerfreundlich. Hacktoberfest-Issues durchsuchen

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

Offen
#2,205 0 Kommentare 0 Reaktionen 0 zugewiesene Personen Auf GitHub ansehen

Dieses Issue hat noch niemand übernommen.

Bewertung

Schwierigkeit
3/5
Geschätzter Aufwand
1-2 Tage
Anfängerfreundlichkeit
48/100
Issue-Typ
Bug
Klarheit
Größtenteils klar
Aktivitätsstatus
Veraltet
Tech-Stack
r

Rechercherichtung

Beginne damit, das reproduzierbare R-Beispiel im Issue auszuführen und nachzuverfolgen, wie ggplotly die zero-contour-Ebene behandelt, die durch die fehlende Faktorstufe erzeugt wird. Als erledigt gilt dies, wenn der Plot nicht mehr den Fehler bei der Dataframe-Ersetzung auslöst und gleichzeitig die informativen zero-contour-Warnungen beibehält.

Vom Indexierungsmodell aus dem Issue-Text verfasst.

Beschreibung

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)
Vorherrschende Sprache
R
Sterne
2.7k
Forks
640
PR-Merge-Kennzahlen
Keine gemergten PRs in 30 T.

Entwicklungsumgebung

Erste Schritte

  1. Lesen Sie das ganze Issue und danach den Beitragsleitfaden des Projekts.
  2. Schreiben Sie ins Issue, dass Sie es übernehmen — das erspart doppelte Arbeit.
  3. Forken Sie das Repository und arbeiten Sie in einem Branch.
  4. Öffnen Sie einen Pull Request, der die Issue-Nummer nennt.

Mehr aus plotly/plotly.R

Alle Issues in plotly/plotly.R

Ähnliche Issues

Weitere Issues zu R

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.