library(raster)
library(ggplot2)
library(sf)
temp.shp <- getData('GADM', country='FRA', level = 2)
temp.shp <- st_as_sf(temp.shp)
dat <- data.frame(CC_2 = rep(temp.shp$CC_2, times = 3),
value = c(sample(1:100, length(temp.shp$CC_2), replace = T),
sample(0.1:1, length(temp.shp$CC_2), replace = T),
sample(-1:-100, length(temp.shp$CC_2), replace = T)),
client = rep(c('a','b','c'), each = length(temp.shp$CC_2)))
dat.shp <- merge(temp.shp, dat, by = 'CC_2')
ggplot() +
geom_sf(data = dat.shp, aes(fill = value), colour = NA) +
scale_fill_viridis_c(option = 'C') +
facet_wrap(~client)
Я хочу, чтобы у каждой панели была своя легенда, поскольку диапазон легенд различен
ggplot() +
geom_sf(data = dat.shp, aes(fill = value), colour = NA) +
scale_fill_viridis_c(option = 'C') +
facet_wrap(~client, scales = 'free')
# Error: coord_sf doesn't support free scales