如何更改 geom_sf 中的 alpha?

How to change alpha in geom_sf?

有没有办法把alpha改成geom_sf?此示例来自 ?geom_sf 中的示例。我尝试添加 alpha=.2 但它似乎忽略了这种美学,尽管 alphageom_line 的公认美学。它不会忽略 fill 的 alpha - 虽然在这个例子中是 NA

library(sf)
#> Linking to GEOS 3.6.1, GDAL 2.1.3, proj.4 4.9.3
library(ggplot2)

nc <- sf::st_read(system.file("shape/nc.shp", package = "sf"), quiet = TRUE)
nc_3857 <- sf::st_transform(nc, "+init=epsg:3857")

ggplot() + geom_sf(data = nc) + 
  geom_sf(data = nc_3857, colour = "red", fill = NA, alpha = 0.2)

这叫做大纲。我从来没有使用过地图,结果不是很漂亮,但我希望这仍然有帮助,这可以帮助你更多:

library(sf)
#> Linking to GEOS 3.6.1, GDAL 2.1.3, proj.4 4.9.3
library(ggplot2)

nc <- sf::st_read(system.file("shape/nc.shp", package = "sf"), quiet = TRUE)
nc_3857 <- sf::st_transform(nc, "+init=epsg:3857")

ggplot() + geom_sf(data = nc) + 
  geom_sf(data = nc_3857, color=alpha("red",0.2))