# ensures that the ranges of axes are equal to the specified ratio by
# adjusting the plot aspect ratio
if (require("maps")) {
# Create a lat-long dataframe from the maps package
nz <- map_data("nz")
# Prepare a plot of the map
nzmap <- ggplot(nz, aes(x = long, y = lat, group = group)) +
geom_polygon(fill = "white", colour = "black")
# Plot it in cartesian coordinates
nzmap
# With correct mercator projection
nzmap + coord_map()
# With the aspect ratio approximation
nzmap + coord_quickmap()
}
# Resize the plot to see that the specified aspect ratio is maintained
Run the code above in your browser using DataLab