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

Labels can overlap in coord_sf() #2119

Closed
adrfantini opened this issue Apr 29, 2017 · 5 comments
Closed

Labels can overlap in coord_sf() #2119

adrfantini opened this issue Apr 29, 2017 · 5 comments
Labels
reprex needs a minimal reproducible example

Comments

@adrfantini
Copy link

Labels in coord_sf() sometimes overlap. This happens when one of the grid lines has some part inside of the plot, but intersect an axis outside of the plot.

See reprex below, look at the bottom left corner, 80W and 82W overlap.

nc <- sf::st_read(system.file("shape/nc.shp", package = "sf"), quiet = TRUE)
ggplot(nc) +
  geom_sf(aes(fill = AREA)) +
  coord_sf(crs="+proj=lcc")
@hadley
Copy link
Member

hadley commented Jun 1, 2017

Can you please create your reprex with the reprex package?

@hadley hadley added the reprex needs a minimal reproducible example label Jun 1, 2017
@adrfantini
Copy link
Author

adrfantini commented Jun 1, 2017

@hadley I cannot because:

> reprex({nc <- sf::st_read(system.file("shape/nc.shp", package = "sf"), quiet = TRUE); ggplot2::ggplot(nc) + ggplot2::geom_sf(ggplot2::aes(fill = AREA)) + ggplot2::coord_sf(crs="+proj=lcc")})
Error in reprex_(r_file) : 
Cannot render this code.
Error in UseMethod("xmlApply") : 
  no applicable method for 'xmlApply' applied to an object of class "raw"

I don't have time to dig through it. However just copypasting the code results in this. Look at the bottom left labels. This is with the gitHub version of ggplot2 of course.

@edzer
Copy link
Contributor

edzer commented Jun 6, 2017

Thanks; I can see what goes wrong; we need to check whether this needs to be solved on the ggplot2 side or on the sf side -- sf::st_graticule is used to compute the graticules and their labels.

Also, I see a 38N (or 38N and 36N overplotted?) at the top left that is placed wrongly as well.

@adrfantini
Copy link
Author

Thanks Edzer, yes something is wrong at the top left as well. Thanks for taking a look at it, this is currently preventing me from using geom_sf() for publication-ready graphics.

edzer added a commit to r-spatial/sf that referenced this issue Jun 6, 2017
@edzer
Copy link
Contributor

edzer commented Jun 6, 2017

You'll need this PR, along with a fresh sf checkout from github.

@hadley hadley closed this as completed in 04a707e Jun 22, 2017
hadley pushed a commit that referenced this issue Jul 3, 2017
* addresses #2119

* tidy graticule fixes

* ggplot2 side of issue r-spatial/sf#396

* tabs -> spaces

* add ndiscr to docs
karawoo pushed a commit that referenced this issue Jul 28, 2017
* addresses #2119

* tidy graticule fixes

* ggplot2 side of issue r-spatial/sf#396

* tabs -> spaces

* add ndiscr to docs

* fix #2200

* attempt to fix #2060

All cases were in sf.R a geometry column is address with x$geometry, ggplot2 made the wrong assumption that the geometry column has a fixed name. I replaced this in certain instances, where the data are already pretty transformed and no longer have properties of sf objects, with a fixed position, i.e. x[[1]], which seems to work.

* fixes r-spatial/sf#438

* address review comments

* fix break on geom_raster, objects without list-column

see https://gist.github.com/mdsumner/573ec70014df177baa2d1df7e55e1943 for the case that this PR fixes

* tidy up

* trying @karawoo's suggestion

* adds some sf tests

* tidy further
@lock lock bot locked as resolved and limited conversation to collaborators Jun 18, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
reprex needs a minimal reproducible example
Projects
None yet
Development

No branches or pull requests

3 participants