Error with coord_map
Closed this issue · 2 comments
DavZim commented
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?
oswaldosantos commented
DavZim commented
I have ggsn version 0.4.0 installed (latest CRAN version). But good to know that newer versions will work.