Skip to content

Commit 5b928ae

Browse files
authored
Pull GeomSf linetype from GeomPolygon/GeomLine (#6661)
* pull `linetype` from GeomPolygon/GeomLine * defend against character linetypes * add news bullet
1 parent 2d8de78 commit 5b928ae

File tree

2 files changed

+7
-1
lines changed

2 files changed

+7
-1
lines changed

NEWS.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
# ggplot2 (development version)
22

3+
* The default linetype in `geom_sf()` is derived from `geom_polygon()` for
4+
polygons and from `geom_line()` for (multi)linestrings (@teunbrand, #6543).
35
* Using infinite `radius` aesthetic in `geom_spoke()` now throws a warning
46
(#6671)
57
* Scales and guides specified by a string can now use package name prefixes to

R/geom-sf.R

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,7 @@ GeomSf <- ggproto("GeomSf", Geom,
126126
fill = NULL,
127127
size = NULL,
128128
linewidth = NULL,
129-
linetype = from_theme(linetype),
129+
linetype = NULL,
130130
alpha = NA,
131131
stroke = 0.5
132132
),
@@ -200,6 +200,10 @@ GeomSf <- ggproto("GeomSf", Geom,
200200

201201
# Recombine data in original order
202202
data <- vec_c(points, lines, others, collections)
203+
# Avoids NA linetype in points, which is invalid input
204+
data$linetype[vec_seq_along(points)] <-
205+
if (is.character(data$linetype)) "solid" else 1L
206+
203207
vec_slice(data, order(unlist(index)))
204208
},
205209

0 commit comments

Comments
 (0)