Skip to content

Second axis doesn't appear when used with coord_map() #2291

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
Nekochef opened this issue Oct 12, 2017 · 1 comment
Closed

Second axis doesn't appear when used with coord_map() #2291

Nekochef opened this issue Oct 12, 2017 · 1 comment

Comments

@Nekochef
Copy link

Nekochef commented Oct 12, 2017

This issue appears when I'm trying to plot a map with axes on all the sides.
Here is an example:

if (require("maps"))
    states <- map_data("state")
    arrests <- USArrests
    names(arrests) <- tolower(names(arrests))
    arrests$region <- tolower(rownames(USArrests))

    choro <- merge(states, arrests, sort = FALSE, by = "region")
    choro <- choro[order(choro$order),]
    ggplot(choro, aes(long, lat)) +
    geom_polygon(aes(group = group, fill = assault)) +
    coord_map("rectangular", 38) +
    scale_y_continuous(sec.axis = dup_axis()) +
    scale_x_continuous(sec.axis = dup_axis())

And the map looks like:
image
As you can see, the second axes only appear with their names but not their labels and ticks.

It seems that this issue exists not only with coord_polar:> #2072.

And if I change coord_map() to coord_quickmap():

if (require("maps"))
    states <- map_data("state")
    arrests <- USArrests
    names(arrests) <- tolower(names(arrests))
    arrests$region <- tolower(rownames(USArrests))

    choro <- merge(states, arrests, sort = FALSE, by = "region")
    choro <- choro[order(choro$order),]
    ggplot(choro, aes(long, lat)) +
    geom_polygon(aes(group = group, fill = assault)) +
    coord_quickmap() +
    scale_y_continuous(sec.axis = dup_axis()) +
    scale_x_continuous(sec.axis = dup_axis())

The code works fine:
image

@hadley
Copy link
Member

hadley commented Oct 30, 2017

Unforunately, dual axes are currently only supported with Cartesian coordinate systems.

@hadley hadley closed this as completed Oct 30, 2017
@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
None yet
Projects
None yet
Development

No branches or pull requests

2 participants