I am plotting spatial point data ( sf
) with ggplot2
. Color is mapped to an associated value. The legend for color is unexpectedly using a polygon shape as it would for a two-dimensional geom that might have separate color and fill attributes. Is there a way to specify that the shape for the color legend so that I can make it a filled circle?
library(sf)
library(ggplot2)
set.seed(2)
df <- data.frame(x = runif(10, min = 0, max = 10),
y = runif(10, min = 0, max = 10),
value = sample(c(FALSE, TRUE), 10, replace = TRUE))
sf <- st_as_sf(df, coords = c("x", "y"))
ggplot(sf, aes(color=value)) +
geom_sf()
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.