问题
I need to crop a plot so that the axes are precisely set on a known x and y line. coord_cartesian
does not behave in this way (see below). So for instance, in the image below I would like the axis to sit directly on the 30 or 40 marks. Any ideas would be greatly appreciated as this is prooving a difficult thing to google!
Edit: This was marked as a duplicate and the question may be a duplicate but the answer I got is different from those in the marked duplicates, and in my view simpler and better.

library(ggplot2)
library(cowplot)
library (rgdal)
library (rgeos)
library(maptools)
poly <- readShapePoly("Countries_WGS84/Countries_WGS84.shp")
polygon <- fortify(poly)
map <- ggplot() +
geom_polygon(data=polygon, aes(long, lat, group = group)) +
coord_cartesian(xlim=c(2, 12),c(30,40))
save_plot("map.png",map ,base_asp = 1, base_height = 10)
来源:https://stackoverflow.com/questions/59079147/how-to-precisely-set-the-axis-position