Skip to content

Warning: Ignoring unknown aesthetics: x, y with geom_map #1810

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

Closed
hrbrmstr opened this issue Oct 3, 2016 · 5 comments
Closed

Warning: Ignoring unknown aesthetics: x, y with geom_map #1810

hrbrmstr opened this issue Oct 3, 2016 · 5 comments

Comments

@hrbrmstr
Copy link
Contributor

hrbrmstr commented Oct 3, 2016

Before I go a-hunting and "fixing" ggalt::coord_proj() I just wanted to make sure that (a) you knew that the examples for geom_map() toss Warning: Ignoring unknown aesthetics: x, y since, well, there are no aesthetics for it anymore and, (b) that this is a desired/designed change (so I know I should compensate for it).

If this is deliberate, I'll take care of the examples for mapping in the ggplot2 package and send in a PR for you to ensure the warnings don't happen.

UPDATE

I think the mapping geom stuff may be broken.

If the x & y aesthetics are really no longer needed I should be able to do:

library(ggplot2)

world <- map_data("world")
world <- world[world$region != "Antarctica",]

ggplot() + geom_map(data=world, map=world, aes(map_id=region))

but that gives a blank map.

If I do:

ggplot() + geom_map(data=world, map=world, aes(x=long, y=lat, map_id=region))

Then I get a map and the Warning: Ignoring unknown aesthetics: x, y.

If I do:

ggplot() + geom_map(data=world, map=world, aes(map_id=region)) + coord_map()

I get:

Error in data.frame(x = x.major, y = y.range[1]) : arguments imply differing number of rows: 0, 1

(same for coord_proj() since I mirrored the coord_map() idiom very closely).

This:

ggplot() + geom_map(data=world, map=world, aes(x=long, y=lat, map_id=region)) + coord_map()

makes the usual broken mercator world map (but it renders expectedly)

This:

ggplot() + geom_map(data=world, map=world, aes(x=long, y=lat, map_id=region)) + coord_proj()

Errors out after the points are projected with:

Error in gPathFromVector(names) : a 'grob' path must contain at least one 'grob' name

which is probably on me as I suspect that there was a valid ggplot2 API change that I need to match in coord_proj() (and it may just be that some of the utility code I needed to embed in ggalt from ggplot2 needs an update).

@hadley
Copy link
Member

hadley commented Oct 3, 2016

It's an unanticipated change, but it is correct I believe. I honestly don't remember much about geom_map() though. I trust your judgement.

@hrbrmstr
Copy link
Contributor Author

hrbrmstr commented Oct 3, 2016

I added more detail from some basic tests. I have some cycles in the next 48 hours to poke at this on the ggplot2 side if you and/or @thomasp85 want an extra set of hands on this.

@thomasp85
Copy link
Member

Much appreciated. I'm in "new job"-mode so I'll have less time in the next week or so but will be responding and advising. I'll deal with any facet related issues of course

@hrbrmstr
Copy link
Contributor Author

hrbrmstr commented Oct 3, 2016

Cool. I'm on this and will update prbly either very late tonight or tomorrow AM (EDT).

@hadley
Copy link
Member

hadley commented Oct 5, 2016

Ok, the problem with the examples is the use of expand_limits() (#1795). That's because geom_map() doesn't work in such a way that ggplot2 knows the extend of the map values, so you always have to expand it by hand yourself.

I think that means this is not a problem with geom_map() (since it hasn't changed), and is instead just a problem with expand_limits().

@hadley hadley closed this as completed Oct 5, 2016
@lock lock bot locked as resolved and limited conversation to collaborators Jun 19, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants