vog
vog

Reputation: 836

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

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.

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

Upvotes: 1

Views: 184

Answers (1)

vog
vog

Reputation: 836

  • 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.

Upvotes: 1

Related Questions