I first posted this as an issue on the ggspatial Github repo, but thought there might be more activity here. My apologies if this is a faux pas – I can delete one or the other.
The carto light basemap looks very different depending on when I include annotation_map_tile()
in my ggplot. (See bottom for my reprex.)
When I include it first, the basemap is light:
ggplot() +
tiles +
geom_spatvector(data = corners, fill = NA, color = "black")
The image is darker when I include it after another layer:
ggplot() +
geom_spatvector(data = corners, fill = NA, color = "black") +
tiles
I imagine the tiles are the same, so maybe it's something to do with opacity? I have set alpha = 1
, and the color difference remains when I ensure there is no panel background.
Reprex
library(ggplot2)
library(ggspatial)
library(terra)
corners <- vect(
data.frame(lon = c(91.11226, 91.24588), lat = c(23.38367, 23.48849)),
geom = c("lon", "lat"),
crs = "epsg:4326")
tiles <- annotation_map_tile(type = "cartolight", zoom = 14, alpha = 1)
ggplot() +
tiles +
geom_spatvector(data = corners, fill = NA, color = "black")
ggsave("tiles-first.png", width = 5, height = 5)
ggplot() +
geom_spatvector(data = corners, fill = NA, color = "black") +
tiles
ggsave("tiles-second.png", width = 5, height = 5)
The effect is the same when I include theme(panel.background = element_rect(fill = "white"))
after ggplot()