Size legend of sf object won't show correct symbols

旧巷老猫 提交于 2020-01-13 10:45:53

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!