diff --git a/NEWS.md b/NEWS.md index 12ad2c0612..f3275ccf7c 100644 --- a/NEWS.md +++ b/NEWS.md @@ -1,5 +1,7 @@ # ggplot2 (development version) +* `geom_curve()` now appropriately removes missing data instead of throwing + errors (@teunbrand, #5831). * `update_geom_defaults()` and `update_stat_defaults()` have a reset mechanism when using `new = NULL` and invisible return the previous defaults (#4993). * Fixed regression in axes where `breaks = NULL` caused the axes to disappear diff --git a/R/geom-curve.R b/R/geom-curve.R index 7ef935caeb..079bf636df 100644 --- a/R/geom-curve.R +++ b/R/geom-curve.R @@ -47,6 +47,11 @@ GeomCurve <- ggproto("GeomCurve", GeomSegment, if (!coord$is_linear()) { cli::cli_warn("{.fn geom_curve} is not implemented for non-linear coordinates") } + data <- remove_missing( + data, na.rm = na.rm, + c("x", "y", "xend", "yend", "linetype", "linewidth"), + name = "geom_curve" + ) trans <- coord$transform(data, panel_params)