When you add geom_text
, it inherits all of the aesthetics you specified inside ggplot
- but because you are using different data for geom_text
, it can't find .estimate
. You can just move aes(fill = .estimate)
from inside ggplot
to inside geom_sf
.
drought_sf %>%
left_join(drought_rmse, by = 'GEOID') %>%
ggplot() +
geom_sf(color = NA, alpha = 0.8, aes(fill = .estimate)) +
labs(fill = "RMSE") +
scale_fill_viridis_c(labels = scales::dollar_format()) +
geom_text(
data = cities_data,
aes(x = long, y = lat, label = fixed_name),
color = 'black',
check_overlap = TRUE
)