Locate value "0" in the center of the Palette in a world map

181 Views Asked by At

I am currently analysing the effect of certain indexes over world countries (134). This effect ranges from (-1.01, 0.528). Given that "effect = 0" is located to the right of the Palette, it does not coincide with the change between greens and yellows and therefore the map is misleading.

  • How can I "center" the value 0 in the scale of the palette? Would be amazing to assign a certain color for those values on the region of 0 (apart from the size, being positive or negative is of crucial importance in my analysis).

  • Is there a way of make a palette of "reds" for negative values and a palette of "greens" for the positive ones?

  • How can I remove the title "index_effect"?

Any clue?

Thank you

Note: The video I have followed to work with this code is here https://www.youtube.com/watch?v=8dNBWESwcHU

The code and the plot I have obtained is the following:

# set the colour
colourPalette <- RColorBrewer::brewer.pal(10,'Spectral') 
# plot the info in the world map ("world_data" is my dataset)
mapCountryData(world_data,
               nameColumnToPlot = 'index_effect',
               catMethod = 'fixedwidth',
               mapRegion = 'world',
               colourPalette = 'diverging',
               numCats = 10)

enter image description here

1

There are 1 best solutions below

1
vog On BEST ANSWER
  • One solution is to standardised the variable index_effect (so it ranges from -1 to 1). In this way 0 will be in the middle of Palette. However, this re-scaling transforms the value of interest (which is something to avoid) and still does not make the trick of having one "red" Palette for the negative values and one "green" Palette for the positive values.
  • Another solution is to make 2 different plots: One for those countries with negative values, the other one for those countries with positive values.