Reputation: 3486
Is there a way to change alpha
with geom_sf
? This example is from the examples in ?geom_sf
. I tried adding alpha=.2
but it seems to ignore that aesthetic, although alpha
is an accepted aesthetic for geom_line
. It does not ignore alpha for the fill
- which in this example is NA
though.
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)
Upvotes: 14
Views: 11111
Reputation: 13
Also alpha, can be clashing with other packages, i would recommend to specify which package you are using. In my case I had to
color = scales::alpha('#c55252', 0.3)
Upvotes: 0
Reputation: 1600
It's called an outline. I never worked with maps and the result is not quite pretty but I hope this is still helpful and this could help you more: ggplot2: different alpha values for border and filling of geom_point
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))
Upvotes: 20