Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

geom_sf alpha not working for linestring #311

Closed
sebdalgarno opened this issue Apr 24, 2017 · 7 comments
Closed

geom_sf alpha not working for linestring #311

sebdalgarno opened this issue Apr 24, 2017 · 7 comments

Comments

@sebdalgarno
Copy link

I expected alpha to work for linestring sf object as in geom_line. Here is a simple example:

library(ggplot2)
library(sf)

l <- st_linestring(rbind(c(2,2), c(3,3), c(3,2)))
lsf <- st_sf(geometry = st_sfc(l, crs = 4326))

ggplot(data = lsf) + geom_sf(data = lsf, lwd = 2)
ggplot(data = lsf) + geom_sf(data = lsf, alpha = 0.5, lwd = 2)

both plots above are identical.

If I try with polygon, fill transparency changes but outline remains the same.
p <- st_polygon(list(rbind(c(2,2), c(3,3), c(3,2), c(2,2))))
psf <- st_sf(geometry = st_sfc(p, crs = 4326))

ggplot(data = psf) + geom_sf(data = psf)
ggplot(data = psf) + geom_sf(data = psf, alpha = 0.5)

Using geom_line, it works:
lpt <- st_coordinates(lsf) %>% tbl_df()
ggplot() + geom_line(data = lpt, aes(x = X, y = Y), alpha = 0.2)

@edzer
Copy link
Member

edzer commented Apr 24, 2017

Since this concerns ggplot2, I'm adding @hadley

@hadley
Copy link
Contributor

hadley commented Apr 24, 2017

Yeah, the support for non-polygon features is not great. I'm aware of it and will look at in more detail when I'm next working on ggplot2 (so feel free to close this issue)

@Gustavoetal
Copy link

Error in geom_sf() : could not find function "geom_sf" still have this issue hot to fix?

@karldw
Copy link
Contributor

karldw commented Feb 24, 2018

@Gustavoetal, are you using the development version of ggplot2? The CRAN version doesn't have geom_sf yet. See the news for the next release.

@Gustavoetal
Copy link

Yes that was the case, I have the stable version and now is working, thanks

@seanhardison1
Copy link

Has alpha for linestrings been implemented yet in geom_sf?

@statnmap
Copy link
Contributor

statnmap commented Nov 2, 2019

It does not seem so but a new issue has been opened on the ggplot2 side: tidyverse/ggplot2#3589

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

7 participants