I'm trying to draw map using a shapefile. The shapefile (prov2022) is this
COD_REG = is the code of the regions.
COD_PROV = is the code of the provices.
Here an example of the dataset instead
COD_PROV Province Real wage
1 Torino 1962,18
6 Alessandria 1742,85
5 Asti 1541,81
96 Biella 1612,2
4 Cuneo 1574
3 Novara 1823,53
103 Verbano -Cusio-Ossola 1584,49
2 Vercelli 1666,21
7 Aosta 1747,81
10 Genova 2066,42
8 Imperia 1498,01
11 La Spezia 1871,34
9 Savona 1770,41
15 Milano 2240,03
16 Bergamo 1729,17
17 Brescia 1773,38
13 Como 1832,57
I'm drawing the map using this script ( which works perfectly)
right_join(prov2022, dataset, by = "COD_PROV") %>%
ggplot(aes(fill = `Real wage`)) +
geom_sf() +
theme_void() +
theme(legend.title=element_blank())+
scale_fill_gradientn(colors = c( "#FFFFFF","#FFFF00", "#FF0000", "#000000"))
The map I get is divided inside according with the borders of each province. Is there a way to draw in bold also the geographical boundaries of the regions?? ( each region has inside 6/7 provinces)
If you don't have the shapefile info on each region (i.e. one big geometry that includes all of its provinces), then it's best to create those for each region first in a separate dataframe. Then you can easily plot them as another layer (with a thicker 'linewidth' argument) to get your desired effect. e.g.
regions <- prov2022 %>%
group_by(COD_REG) %>%
summarize(geometry = st_union(geometry))
right_join(prov2022, dataset, by = "COD_PROV") %>%
ggplot() +
geom_sf(aes(fill = `Real wage`) +
theme_void() +
theme(legend.title=element_blank())+
scale_fill_gradientn(colors = c( "#FFFFFF","#FFFF00", "#FF0000", "#000000")) +
geom_sf(data = regions, aes(geometry = geometry), linewidth = 2, fill = NA)