oswaldosantos/ggsn

Error with coord_map

Closed this issue · 2 comments

When I try to use ggsn on a ggplot-map, I get an error when using coord_map. I do see that certain map projections might cause an error (where to point to north on a globe for example), but in the default map projection it would not cause an issue (as far as I understand it).

Here is an example:

library(ggsn)
#> Loading required package: ggplot2

# following loosely the example in ?map_data (ggplot2)

## Data Preparation
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), ]

# Map Creation
figure_map <- ggplot(choro, aes(long, lat)) +
  geom_polygon(aes(group = group, fill = assault))

The base map without coord map

## A minimum case
figure_map

figure_map + north(choro, symbol = 16, scale = 0.15)

Map + coord map

## Coordinates of a Map
figure_map + coord_map()

figure_map + coord_map() + north(choro, symbol = 16, scale = 0.15)
#> Error: annotation_custom only works with Cartesian coordinates

Any chance to fix this easily?

The code works for me with maps_3.2.0, ggsn_0.4.6 and ggplot2_2.2.1.9000.
rplot
Try again after updating the packages.

I have ggsn version 0.4.0 installed (latest CRAN version). But good to know that newer versions will work.