SF对象的尺寸图例不会显示正确的符号 [英] Size legend of sf object won't show correct symbols

查看:93
本文介绍了SF对象的尺寸图例不会显示正确的符号的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有人知道为什么size静态BIR74的图例不显示点大小而是矩形吗?如果答案是肯定的,我该如何解决?

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?

可复制的示例:

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中,即

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()

这篇关于SF对象的尺寸图例不会显示正确的符号的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆