sf 对象的尺寸图例不会显示正确的符号
Size legend of sf object won't show correct symbols
有谁知道为什么 size
aestatic BIR74
的图例不会显示点大小而是矩形?如果答案是肯定的,我该如何解决?
可重现的例子:
library(sf)
# devtools::install_github("tidyverse/ggplot2")
library(ggplot2)
nc <- st_read(system.file("shape/nc.shp", package="sf"))
nc_centers <- st_centroid(nc)
nc_centers %>%
ggplot() +
geom_sf(aes(color = SID79, size = BIR74)) +
coord_sf(datum = NA) +
theme_minimal()
您需要将 show.legend 参数添加到 geom_sf,即
nc_centers %>%
ggplot() +
geom_sf(aes(color = SID79, size = BIR74), show.legend = 'point') +
coord_sf(datum = NA) +
theme_minimal()
有谁知道为什么 size
aestatic BIR74
的图例不会显示点大小而是矩形?如果答案是肯定的,我该如何解决?
可重现的例子:
library(sf)
# devtools::install_github("tidyverse/ggplot2")
library(ggplot2)
nc <- st_read(system.file("shape/nc.shp", package="sf"))
nc_centers <- st_centroid(nc)
nc_centers %>%
ggplot() +
geom_sf(aes(color = SID79, size = BIR74)) +
coord_sf(datum = NA) +
theme_minimal()
您需要将 show.legend 参数添加到 geom_sf,即
nc_centers %>%
ggplot() +
geom_sf(aes(color = SID79, size = BIR74), show.legend = 'point') +
coord_sf(datum = NA) +
theme_minimal()