From ec330795e45d29e1cbd3751ad02f4203f9dfda70 Mon Sep 17 00:00:00 2001 From: Teun van den Brand Date: Mon, 29 Sep 2025 15:50:39 +0200 Subject: [PATCH 1/2] pull `linetype` from GeomPolygon/GeomLine --- R/geom-sf.R | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/R/geom-sf.R b/R/geom-sf.R index 177c30f933..829146a0d8 100644 --- a/R/geom-sf.R +++ b/R/geom-sf.R @@ -126,7 +126,7 @@ GeomSf <- ggproto("GeomSf", Geom, fill = NULL, size = NULL, linewidth = NULL, - linetype = from_theme(linetype), + linetype = NULL, alpha = NA, stroke = 0.5 ), @@ -161,6 +161,7 @@ GeomSf <- ggproto("GeomSf", Geom, vec_slice(data, index$point), params, modifiers, theme = theme ) + points$linetype <- 1L # Avoids NA linetype, which is invalid input } if (length(index$line) > 0) { lines <- GeomLine$use_defaults( From e78901769c765908afc634472d63d34400f94e54 Mon Sep 17 00:00:00 2001 From: Teun van den Brand Date: Mon, 29 Sep 2025 16:20:48 +0200 Subject: [PATCH 2/2] defend against character linetypes --- R/geom-sf.R | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/R/geom-sf.R b/R/geom-sf.R index 829146a0d8..41e74ba3cb 100644 --- a/R/geom-sf.R +++ b/R/geom-sf.R @@ -161,7 +161,6 @@ GeomSf <- ggproto("GeomSf", Geom, vec_slice(data, index$point), params, modifiers, theme = theme ) - points$linetype <- 1L # Avoids NA linetype, which is invalid input } if (length(index$line) > 0) { lines <- GeomLine$use_defaults( @@ -201,6 +200,10 @@ GeomSf <- ggproto("GeomSf", Geom, # Recombine data in original order data <- vec_c(points, lines, others, collections) + # Avoids NA linetype in points, which is invalid input + data$linetype[vec_seq_along(points)] <- + if (is.character(data$linetype)) "solid" else 1L + vec_slice(data, order(unlist(index))) },