-
Notifications
You must be signed in to change notification settings - Fork 2.1k
Feature Request: Add 'clip' argument to coord_sf() #2938
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
Comments
Yes, absolutely. I'm embarrassed that I missed that one. We're too late for ggplot2 3.1.0, but this can be done for the next release. As workaround, you can probably just assign your crd <- coord_sf(...)
crd$clip <- "off"
ggplot() + ... + crd I haven't tried this but I assume this will work. |
Thanks, @clauswilke! I can confirm that that workaround does indeed work. crd <- coord_sf()
crd$clip <- "off"
my_plot + crd |
@clauswilke we can probably squeeze it in - I forgot to submit last week, and I'm travelling until Thursday. |
@hadley I made a PR: #2942 @bschneidr Could you install the branch with the added feature and test? Let me know if you need help installing. |
Beautiful! It worked like a charm. library(ggplot2) # Installed using devtools::install_github("tidyverse/ggplot2#2942")
library(dplyr)
library(sf)
library(tigris)
# Download the Louisville-area shapefile from Census Bureau using tigris
ky_zcta_sf <- tigris::zctas(cb = TRUE,
class = 'sf',
state = "KY", year = 2016) %>%
filter(startsWith(ZCTA5CE10, "402"))
# Plot the ZIP codes of Louisville
ggplot(ky_zcta_sf) +
geom_sf(fill = "#39499C", color = "white") +
geom_text(x = -85.325, y = 38.15,
label = "Out-of-bounds\ntext") +
scale_x_continuous(limits = c(-86, -85.35)) +
coord_sf(clip = 'off') +
theme(plot.margin = unit(c(.1, .5, .1, .1), 'in')) Created on 2018-10-16 by the reprex package (v0.2.1.9000) Session infodevtools::session_info()
#> Session info -------------------------------------------------------------
#> setting value
#> version R version 3.5.1 (2018-07-02)
#> system x86_64, mingw32
#> ui RTerm
#> language (EN)
#> collate English_United States.1252
#> tz America/New_York
#> date 2018-10-16
#> Packages -----------------------------------------------------------------
#> package * version date source
#> assertthat 0.2.0 2017-04-11 CRAN (R 3.5.0)
#> base * 3.5.1 2018-07-02 local
#> bindr 0.1.1 2018-03-13 CRAN (R 3.4.3)
#> bindrcpp * 0.2.2 2018-03-29 CRAN (R 3.5.0)
#> class 7.3-14 2015-08-30 CRAN (R 3.5.0)
#> classInt 0.2-3 2018-04-16 CRAN (R 3.5.0)
#> colorspace 1.3-2 2016-12-14 CRAN (R 3.5.0)
#> compiler 3.5.1 2018-07-02 local
#> crayon 1.3.4 2017-09-16 CRAN (R 3.5.0)
#> curl 3.2 2018-03-28 CRAN (R 3.5.0)
#> datasets * 3.5.1 2018-07-02 local
#> DBI 1.0.0 2018-05-02 CRAN (R 3.5.1)
#> devtools 1.13.6 2018-06-27 CRAN (R 3.5.0)
#> digest 0.6.18 2018-10-10 CRAN (R 3.5.1)
#> dplyr * 0.7.6 2018-06-29 CRAN (R 3.5.0)
#> e1071 1.7-0 2018-07-28 CRAN (R 3.5.1)
#> evaluate 0.12 2018-10-09 CRAN (R 3.5.1)
#> foreign 0.8-71 2018-07-20 CRAN (R 3.5.1)
#> ggplot2 * 3.0.0.9000 2018-10-16 Github (clauswilke/ggplot2@4a7d994)
#> glue 1.3.0 2018-07-17 CRAN (R 3.5.1)
#> graphics * 3.5.1 2018-07-02 local
#> grDevices * 3.5.1 2018-07-02 local
#> grid 3.5.1 2018-07-02 local
#> gtable 0.2.0 2016-02-26 CRAN (R 3.5.0)
#> htmldeps 0.1.1 2018-07-23 Github (rstudio/htmldeps@c1023e0)
#> htmltools 0.3.6 2017-04-28 CRAN (R 3.5.0)
#> httr 1.3.1 2017-08-20 CRAN (R 3.5.0)
#> knitr 1.20 2018-02-20 CRAN (R 3.5.0)
#> lattice 0.20-35 2017-03-25 CRAN (R 3.5.0)
#> lazyeval 0.2.1 2017-10-29 CRAN (R 3.5.0)
#> magrittr 1.5 2014-11-22 CRAN (R 3.5.0)
#> maptools 0.9-4 2018-09-19 CRAN (R 3.5.1)
#> memoise 1.1.0 2017-04-21 CRAN (R 3.3.3)
#> methods * 3.5.1 2018-07-02 local
#> mime 0.6 2018-10-05 CRAN (R 3.5.1)
#> munsell 0.5.0 2018-06-12 CRAN (R 3.4.4)
#> pillar 1.3.0 2018-07-14 CRAN (R 3.5.1)
#> pkgconfig 2.0.2 2018-08-16 CRAN (R 3.5.1)
#> plyr 1.8.4 2016-06-08 CRAN (R 3.5.0)
#> purrr 0.2.5 2018-05-29 CRAN (R 3.5.0)
#> R6 2.3.0 2018-10-04 CRAN (R 3.5.1)
#> rappdirs 0.3.1 2016-03-28 CRAN (R 3.5.0)
#> Rcpp 0.12.19 2018-10-01 CRAN (R 3.5.1)
#> rgdal 1.3-4 2018-08-03 CRAN (R 3.5.1)
#> rlang 0.2.2 2018-08-16 CRAN (R 3.5.1)
#> rmarkdown 1.10.14 2018-10-16 Github (rstudio/rmarkdown@dcc7d37)
#> scales 1.0.0 2018-08-09 CRAN (R 3.5.1)
#> sf * 0.6-3 2018-05-17 CRAN (R 3.5.0)
#> sp 1.3-1 2018-06-05 CRAN (R 3.5.0)
#> spData 0.2.9.4 2018-09-15 CRAN (R 3.5.1)
#> stats * 3.5.1 2018-07-02 local
#> stringi 1.2.4 2018-07-20 CRAN (R 3.5.1)
#> stringr 1.3.1 2018-05-10 CRAN (R 3.5.0)
#> tibble 1.4.2 2018-01-22 CRAN (R 3.5.0)
#> tidyselect 0.2.5 2018-10-11 CRAN (R 3.5.1)
#> tigris * 0.7 2018-04-14 CRAN (R 3.4.4)
#> tools 3.5.1 2018-07-02 local
#> units 0.6-1 2018-09-21 CRAN (R 3.5.1)
#> utils * 3.5.1 2018-07-02 local
#> uuid 0.1-2 2015-07-28 CRAN (R 3.5.0)
#> withr 2.1.2 2018-03-15 CRAN (R 3.5.0)
#> xml2 1.2.0 2018-01-24 CRAN (R 3.5.0)
#> yaml 2.2.0 2018-07-25 CRAN (R 3.5.1) |
This old issue has been automatically locked. If you believe you have found a related problem, please file a new issue (with reprex) and link to this issue. https://reprex.tidyverse.org/ |
Just as
coord_map()
has a clip argument (e.g.coord_map(clip = 'off')
), it would be useful forcoord_sf()
to have aclip
argument, too.I think these are the two sections of the code that would need to be updated (ignoring the roxygen comments).
ggplot2/R/sf.R
Lines 788 to 792 in 3e1e6e4
ggplot2/R/sf.R
Lines 825 to 835 in 3e1e6e4
The text was updated successfully, but these errors were encountered: