I am trying to create a map depicting the Trade balance (Export minus Imports) of the European countries. I managed to create the map using the code below:
red_color <- "#6875B6"
white <- "#E4E5ED"
blue_color <- "#B66B68"
red_blue_palette <- colorRampPalette(c(blue_color, white, red_color))
colors_map <- red_blue_palette(10)
ggplot(merged) +
geom_sf(aes(fill = value), color = NA, alpha = 0.9) +
geom_sf(data = borders, fill = NA, size = 0.1, col = "grey30") +
coord_sf(
xlim = c(2377294, 6500000),
ylim = c(1413597, 5228510)
) + scale_fill_gradientn(colours = colors_map) + theme_void()
It resulted in the following map:
Now the problem is that some countries appear in red, even though they have a positive trade balance, and ideally they should appear in blue. I would be grateful if anyone can give me a clue as to how to put white at exactly zero, so that countries with a positive trade balance appear in blue instead of red. Thanks.
For those who want to have a look at the merged
data:
> merged
Simple feature collection with 28 features and 6 fields
Geometry type: GEOMETRY
Dimension: XY
Bounding box: xmin: -2823918 ymin: -3076004 xmax: 10025920 ymax: 5307045
Projected CRS: ETRS89-extended / LAEA Europe
First 10 features:
CNTR_ID CNTR_NAME ISO3_CODE NAME_ENGL FID value geometry
1 AT Österreich AUT Austria AT -6381716162 POLYGON ((4832035 2857837, ...
2 BE Belgien-Belgique-België BEL Belgium BE 41394515352 MULTIPOLYGON (((4040360 307...
3 BG България BGR Bulgaria BG -5417941798 POLYGON ((5803878 2477397, ...
4 CY Κύπρος-Kıbrıs CYP Cyprus CY -9656348012 POLYGON ((6474836 1660347, ...
5 CZ Česká Republika CZE Czechia CZ 37209855668 POLYGON ((4660256 3095529, ...
6 DE Deutschland DEU Germany DE 366419598458 MULTIPOLYGON (((4283725 352...
7 DK Danmark DNK Denmark DK 18998047850 MULTIPOLYGON (((4283725 352...
8 EE Eesti EST Estonia EE -1692446146 MULTIPOLYGON (((5333199 417...
9 EL Ελλάδα GRC Greece EL -35943725068 MULTIPOLYGON (((5675519 221...
10 ES España ESP Spain ES -31594000966 MULTIPOLYGON (((3367336 232...
I tried the solution suggested in the comments and I obtained the following:
How can I increase the contrast? Some countries, like Denmark, look almost white, although Denmark has 19 Billion Euros of surplus.