问题
Does anyone know why the legend of the size
aestatic BIR74
won't show the dot sizes but rectangles? If the answer is yes, how can I fix this?
Reproducable example:
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()
回答1:
you need to add the show.legend argument to geom_sf, i.e.
nc_centers %>%
ggplot() +
geom_sf(aes(color = SID79, size = BIR74), show.legend = 'point') +
coord_sf(datum = NA) +
theme_minimal()
来源:https://stackoverflow.com/questions/49555694/size-legend-of-sf-object-wont-show-correct-symbols