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(): POINT geometry doesn't work with shape names #5808

Open
etiennebacher opened this issue Mar 26, 2024 · 2 comments
Open

geom_sf(): POINT geometry doesn't work with shape names #5808

etiennebacher opened this issue Mar 26, 2024 · 2 comments
Labels
layers 📈 tidy-dev-day 🤓 Tidyverse Developer Day rstd.io/tidy-dev-day

Comments

@etiennebacher
Copy link

etiennebacher commented Mar 26, 2024

Hello, in geom_point(), passing shape = 23 or shape = "diamond filled" is the same thing (based on this section from the docs):

library(ggplot2)
library(sf)
#> Linking to GEOS 3.11.2, GDAL 3.7.2, PROJ 9.3.0; sf_use_s2() is TRUE

ggplot(iris, aes(Sepal.Length, Sepal.Width)) +
    geom_point(shape = "diamond filled", color = "red", fill = "black")

ggplot(iris, aes(Sepal.Length, Sepal.Width)) +
    geom_point(shape = 23, color = "red", fill = "black")

However, with geom_sf(), shape = 23 works fine but shape = "diamond filled" doesn’t work anymore:

# from example of geom_sf()
geo_data <- sf::st_read(system.file("shape/nc.shp", package = "sf"), quiet = TRUE) |> 
    sf::st_transform(3857)
geo_data$geometry <- sf::st_centroid(geo_data$geometry)

ggplot(geo_data) +
    geom_sf(shape = 23, color = "red", fill = "black")

ggplot(geo_data) +
    geom_sf(shape = "diamond filled", color = "red", fill = "black")

Session info
sessioninfo::session_info()
#> ─ Session info ───────────────────────────────────────────────────────────────
#>  setting  value
#>  version  R version 4.3.3 (2024-02-29 ucrt)
#>  os       Windows 10 x64 (build 19044)
#>  system   x86_64, mingw32
#>  ui       RTerm
#>  language (EN)
#>  collate  English_Europe.utf8
#>  ctype    English_Europe.utf8
#>  tz       Europe/Paris
#>  date     2024-03-26
#>  pandoc   3.1.1 @ C:/Program Files/RStudio/resources/app/bin/quarto/bin/tools/ (via rmarkdown)
#> 
#> ─ Packages ───────────────────────────────────────────────────────────────────
#>  ! package     * version    date (UTC) lib source
#>  D class         7.3-22     2023-05-03 [1] CRAN (R 4.3.3)
#>    classInt      0.4-10     2023-09-05 [1] CRAN (R 4.3.1)
#>    cli           3.6.2      2023-12-11 [1] CRAN (R 4.3.2)
#>    colorspace    2.1-0      2023-01-23 [1] CRAN (R 4.3.0)
#>    curl          5.2.1      2024-03-01 [1] CRAN (R 4.3.3)
#>    DBI           1.2.2      2024-02-16 [1] CRAN (R 4.3.2)
#>    digest        0.6.35     2024-03-11 [1] CRAN (R 4.3.3)
#>    dplyr         1.1.4      2023-11-17 [1] CRAN (R 4.3.2)
#>    e1071         1.7-14     2023-12-06 [1] CRAN (R 4.3.2)
#>    evaluate      0.23       2023-11-01 [1] CRAN (R 4.3.2)
#>    fansi         1.0.6      2023-12-08 [1] CRAN (R 4.3.2)
#>    farver        2.1.1      2022-07-06 [1] CRAN (R 4.3.0)
#>    fastmap       1.1.1      2023-02-24 [1] CRAN (R 4.3.0)
#>    fs            1.6.3      2023-07-20 [1] CRAN (R 4.3.1)
#>    generics      0.1.3      2022-07-05 [1] CRAN (R 4.3.0)
#>    ggplot2     * 3.5.0      2024-02-23 [1] CRAN (R 4.3.2)
#>    glue          1.7.0      2024-01-09 [1] CRAN (R 4.3.2)
#>    gtable        0.3.4      2023-08-21 [1] CRAN (R 4.3.1)
#>    highr         0.10       2022-12-22 [1] CRAN (R 4.3.0)
#>    htmltools     0.5.8      2024-03-25 [1] CRAN (R 4.3.3)
#>  D KernSmooth    2.23-22    2023-07-10 [1] CRAN (R 4.3.3)
#>    knitr         1.45       2023-10-30 [1] CRAN (R 4.3.1)
#>    labeling      0.4.3      2023-08-29 [1] CRAN (R 4.3.1)
#>    lifecycle     1.0.4      2023-11-07 [1] CRAN (R 4.3.2)
#>    magrittr      2.0.3      2022-03-30 [1] CRAN (R 4.3.0)
#>    munsell       0.5.0      2018-06-12 [1] CRAN (R 4.3.0)
#>    pillar        1.9.0      2023-03-22 [1] CRAN (R 4.3.0)
#>    pkgconfig     2.0.3      2019-09-22 [1] CRAN (R 4.3.0)
#>    proxy         0.4-27     2022-06-09 [1] CRAN (R 4.3.0)
#>    purrr         1.0.2      2023-08-10 [1] CRAN (R 4.3.1)
#>    R.cache       0.16.0     2022-07-21 [1] CRAN (R 4.3.0)
#>    R.methodsS3   1.8.2      2022-06-13 [1] CRAN (R 4.3.0)
#>    R.oo          1.26.0     2024-01-24 [1] CRAN (R 4.3.2)
#>    R.utils       2.12.3     2023-11-18 [1] CRAN (R 4.3.2)
#>    R6            2.5.1      2021-08-19 [1] CRAN (R 4.3.0)
#>    Rcpp          1.0.12     2024-01-09 [1] CRAN (R 4.3.2)
#>    reprex        2.1.0.9000 2024-01-12 [1] Github (tidyverse/reprex@33ccedf)
#>    rlang         1.1.3      2024-01-10 [1] CRAN (R 4.3.2)
#>    rmarkdown     2.26       2024-03-05 [1] CRAN (R 4.3.3)
#>    rstudioapi    0.16.0     2024-03-24 [1] CRAN (R 4.3.3)
#>    scales        1.3.0      2023-11-28 [1] CRAN (R 4.3.2)
#>    sessioninfo   1.2.2      2021-12-06 [1] CRAN (R 4.3.0)
#>    sf          * 1.0-15     2023-12-18 [1] CRAN (R 4.3.2)
#>    styler        1.10.2     2023-08-29 [1] CRAN (R 4.3.1)
#>    tibble        3.2.1      2023-03-20 [1] CRAN (R 4.3.0)
#>    tidyselect    1.2.1      2024-03-11 [1] CRAN (R 4.3.3)
#>    units         0.8-5      2023-11-28 [1] CRAN (R 4.3.2)
#>    utf8          1.2.4      2023-10-22 [1] CRAN (R 4.3.2)
#>    vctrs         0.6.5.9000 2023-12-14 [1] Github (r-lib/vctrs@8bf5ba5)
#>    withr         3.0.0      2024-01-16 [1] CRAN (R 4.3.2)
#>    xfun          0.42       2024-02-08 [1] CRAN (R 4.3.2)
#>    xml2          1.3.6      2023-12-04 [1] CRAN (R 4.3.2)
#>    yaml          2.3.8      2023-12-11 [1] CRAN (R 4.3.2)
#> 
#>  [1] C:/Users/etienne/AppData/Local/Programs/R/R-4.3.3/library
#> 
#>  D ── DLL MD5 mismatch, broken installation.
#> 
#> ──────────────────────────────────────────────────────────────────────────────

I didn't see anything in the docs of geom_sf() or in the docs section linked above mentioning some differences in shape support between geom_sf() and geom_point(). I did a few tests and it seems this is the case for all shape names, not just "diamond filled".

Tried with ggplot2 3.5.0 and Github version.

Thanks

@etiennebacher etiennebacher changed the title geom_sf(): POINT geometry doesn't work with shape full names geom_sf(): POINT geometry doesn't work with shape names Mar 26, 2024
@teunbrand
Copy link
Collaborator

Thanks for the report! I think this should indeed be consistent with geom_point().

@teunbrand
Copy link
Collaborator

It appears straightforward to fix by adding translate_string_shape() at the correct spot. I'll propose this issue for tidy dev day.

@teunbrand teunbrand added layers 📈 tidy-dev-day 🤓 Tidyverse Developer Day rstd.io/tidy-dev-day labels Mar 26, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
layers 📈 tidy-dev-day 🤓 Tidyverse Developer Day rstd.io/tidy-dev-day
Projects
None yet
Development

No branches or pull requests

2 participants