library(ggplot2)
# \donttest{
# 1. Graticule on a WGS84 world map
ggplot() +
geom_world() +
annotation_graticule(
lon_step = 60,
lat_step = 30,
label_offset = 5
) +
coord_sf(crs = "+proj=longlat +datum=WGS84") +
theme_void()
# 2. Robinson projection centred at 150E
crs_robin_150 <- "+proj=robin +lon_0=150 +datum=WGS84"
ggplot() +
geom_world(crs = crs_robin_150) +
annotation_graticule(
crs = crs_robin_150,
lon_step = 30,
lat_step = 15,
label_offset = 3e5
) +
coord_sf(crs = crs_robin_150) +
theme_void()
# 3. Regional China map (long-lat) with graticule lines and axis labels
cn_xlim <- c(70, 140)
cn_ylim <- c(0, 60)
ggplot() +
geom_world() +
annotation_graticule(
xlim = cn_xlim,
ylim = cn_ylim,
crs = 4326,
lon_step = 10,
lat_step = 10,
label_color = NA, # draw only lines; use axis labels instead
label_offset = 1,
label_size = 3.5
) +
coord_sf(
xlim = cn_xlim,
ylim = cn_ylim,
expand = FALSE
) +
labs(
x = "Longitude",
y = "Latitude"
) +
theme_bw()
# }
Run the code above in your browser using DataLab