# GeoRegionValuePlot with a custom color function?

**URL:** <https://community.wolfram.com/t/georegionvalueplot-with-a-custom-color-function/14677>\
**Category:** Questions\
**Tags:** mathematica, graphics-and-visualization, geography\
**Created:** [September 1, 2019, 12:20pm UTC](https://community.wolfram.com/t/georegionvalueplot-with-a-custom-color-function/14677 "2019-09-01T12:20:11Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![grifri](https://yyz1.discourse-cdn.com/wolfram/user_avatar/community.wolfram.com/grifri/32/23694_2.png) [@grifri](https://community.wolfram.com/u/grifri)\
**Post date:** [September 1, 2019, 12:20pm UTC](https://community.wolfram.com/t/georegionvalueplot-with-a-custom-color-function/14677/1 "2019-09-01T12:20:11Z")

</div>

_I used unscaled coordinates with a custom color function to visualize data for life expectancy in African countries (see code below). Five intervals for five colors. But it seems tha WM choses the boundaries of the intervals somehow different. What’s the problem? Thanks!_

```
GeoRegionValuePlot[
EntityClass["Country", "Africa"] -> "LifeExpectancy", 
ColorFunctionScaling -> False, 
ColorFunction -> (Which[70 < #, Pink, 65 < # <= 70, Blue, 
60 < # <= 65, Green, 55 < # <= 60, Gray, 50 < # <= 55, 
Orange] &), ImageSize -> 350, 
GeoLabels -> ((Tooltip[#1, Row[{#2, Spacer[5], #4}]] &))]

```

---

<div class="post-metadata">

**Author:** ![rohitnamjoshi](https://avatars.discourse-cdn.com/v4/letter/r/f1d935/32.png) [@rohitnamjoshi](https://community.wolfram.com/u/rohitnamjoshi)\
**Post date:** [September 2, 2019, 2:49am UTC](https://community.wolfram.com/t/georegionvalueplot-with-a-custom-color-function/14677/2 "2019-09-02T02:49:02Z")

</div>

Hi Gregory,

I think this is similar to [this](https://mathematica.stackexchange.com/q/121130/58370) from 2016. Not sure if WRI acknowledged that it is a bug, but it is reproducible in 12.0. Please add this as an example of a longstanding unresolved issue to [this](https://wolfram.discourse.group/t/14595/15) post.

---

<div class="post-metadata">

**Author:** ![grifri](https://yyz1.discourse-cdn.com/wolfram/user_avatar/community.wolfram.com/grifri/32/23694_2.png) [@grifri](https://community.wolfram.com/u/grifri)\
**Post date:** [September 2, 2019, 5:49am UTC](https://community.wolfram.com/t/georegionvalueplot-with-a-custom-color-function/14677/3 "2019-09-02T05:49:53Z")

</div>

Rohit, thank you for this comment and a link. I’ll append my question to “Bugs Review”.list

---

<div class="post-metadata">

**Author:** ![grifri](https://yyz1.discourse-cdn.com/wolfram/user_avatar/community.wolfram.com/grifri/32/23694_2.png) [@grifri](https://community.wolfram.com/u/grifri)\
**Post date:** [September 15, 2019, 7:30pm UTC](https://community.wolfram.com/t/georegionvalueplot-with-a-custom-color-function/14677/4 "2019-09-15T19:30:54Z")

</div>

Thanks to [Lukas Lang and kglr](https://mathematica.stackexchange.com/questions/204651/georegionvalueplot-with-a-custom-color-function) the answer is as follows:

```
DownValues@System`GeoPlotsDump`iGeoRegionValuePlot = 
  DownValues@System`GeoPlotsDump`iGeoRegionValuePlot /. 
   HoldPattern@
     Rescale[#, 
      minMax : {0, 1} | PatternSequence[], {#2[[1]], Plus @@ #2}] :> 
    Rescale[#, minMax, #2];
cf = Which[70 < #, Pink, 65 < # <= 70, Blue, 60 < # <= 65, Green, 
    55 < # <= 60, Gray, 50 < # <= 55, Orange] &;
GeoRegionValuePlot[
  EntityClass["Country", "Africa"] -> "LifeExpectancy", 
  ColorFunctionScaling -> False, ColorFunction -> cf, 
  ImageSize -> 350, MissingStyle -> Red, 
  GeoLabels -> ((Tooltip[#1, Row[{#2, Spacer[5], #4}]] &)), 
  PlotLegends -> Automatic] /. _BarLegend -> BarLegend[{cf, {50, 75}}]

```
