I have plotted the following map of Philippines according to the population in its regions, using matplotlib.pyplot in Python 3:

enter image description here

As can be seen, there's one province (in red) that is an outlier. When looking at the data, it is clear:

 population = [16.892118644067804,

This is making the plot "unattractive" - there would have been a lot more contrasting colors for the other regions had this one region's data not been an outlier. What options do I have to rectify this?

  1. Remove this region's data. In that case, this region would appear white (uncolored), and the rest will have contrasting colors. But for whatever reason, that's not an option for me currently.
  2. Manually tweak that one data point to "blend in" with the other data points (something like a mean of all the other data points, or even a handcrafted value that is reasonably close to the other data points, like 22, or whatever). I tried this, and this does give more contrasting colors. The trouble is, this is misrepresentation of data. So, if possible, I would like to avoid it.
  3. Stretch the yellow further down in the colormap, so that only a little space is given to red. That is, instead of the 2 colors starting to transition from one to the other around 24 in the colorbar, it should do so around, say, 19. Anybody knows how to do that?

Any other ideas? What are some of the best practice approaches to tackle this issue?

  • $\begingroup$ Is it better if you take the log value? $\endgroup$
    – TQA
    Jun 26, 2018 at 5:11
  • $\begingroup$ You could manually set color range. Right now it is using default from your minimum value of 16.89 to max value of 29.62. You pyplot.clim() to change this range to something like (0, 30). $\endgroup$
    – tomar__
    Jun 26, 2018 at 16:39
  • $\begingroup$ @tomar__ I have already tried. It doesn't produce the desired results. All regions are either "undercolored" (light) or "overcolored" (bright). $\endgroup$ Jun 27, 2018 at 2:00

2 Answers 2


I would recommend two simple but effective methods:

  1. Outliers like that are usually easy to discover by calculating the mean and std of the values and possibly you could set your interval of colors between: $[\mu-\sigma,\mu+\sigma]$. This would 'clip' the outliers toward a generic maximum.

  2. Binning - Instead of giving a specific color to specific country choose a sufficient bin number and group some countries together. You can think about it this way - Does 26.924931506849322 and 26.636250000000004 are really any different? You can have a parametric amount of bins by using it as function of the amount of items you have. Like: ${countries}/{2}$.


With Wolfram Language you may use GeoRegionValuePlot with the ColorFunction option to customise the colour scaling.

With some "AdministrativeDivision" "Population" data for the Philippines.

popPH = EntityValue[
   Entity["Country", "Philippines"]["AdministrativeDivisions"],


Mathematica graphics

Then GeoRegionValuePlot with and without a custom ColorFunction.

linear = GeoRegionValuePlot[popPH,
  ColorFunction -> ColorData["SolarColors"],
  PlotLabel -> "Linear ColorFunction",
  PlotLegends -> Placed[Automatic, Below]

log = GeoRegionValuePlot[popPH,
  ColorFunctionScaling -> False,
  ColorFunction -> (ColorData["SolarColors"][
      Rescale[Log@#, Log@QuantityMagnitude@MinMax[popPH]]] &),
  PlotLabel -> "Log ColorFunction",
  PlotLegends -> Placed[Automatic, Below]

Row[{linear, log}]

Mathematica graphics

Hope this helps.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.