I am trying to get a map with 4 colors, I have several regions with values from 0 to 3 and I want to color those regions with value 0 in white, with value 1 in yellow, with value 2 in orange and with value 3 in red.
I have tried both using ColorFunction
and ColorRules
but Mathematica ignores these directives. Below are my attempts.
Using ColorRules
:
GeoRegionValuePlot[{
Entity["AdministrativeDivision", {"Arkansas", "UnitedStates"}] -> 1,
Entity["AdministrativeDivision", {"California", "UnitedStates"}] -> 0,
Entity["AdministrativeDivision", {"Connecticut", "UnitedStates"}] -> 2,
Entity["AdministrativeDivision", {"Illinois", "UnitedStates"}] -> 3,
Entity["AdministrativeDivision", {"Maryland", "UnitedStates"}] -> 3,
Entity["AdministrativeDivision", {"Massachusetts", "UnitedStates"}] -> 3,
Entity["AdministrativeDivision", {"Montana", "UnitedStates"}] -> 0,
Entity["AdministrativeDivision", {"NewYork", "UnitedStates"}] -> 0,
Entity["AdministrativeDivision", {"NewJersey", "UnitedStates"}] -> 1,
Entity["AdministrativeDivision", {"Ohio", "UnitedStates"}] -> 1,
Entity["AdministrativeDivision", {"RhodeIsland", "UnitedStates"}] -> 2,
Entity["AdministrativeDivision", {"Texas", "UnitedStates"}] -> 0,
Entity["AdministrativeDivision", {"WestVirginia", "UnitedStates"}] -> 0
}, ColorRules -> {0 -> White, 1 -> Yellow, 2 -> Orange, 3 -> Red}]
Using ColorFunction
:
f[x_] := Piecewise[{{White, x == 0}, {Yellow, x == 1}, {Orange, x == 2}, {Red, x == 3}}, 0];
GeoRegionValuePlot[{
Entity["AdministrativeDivision", {"Arkansas", "UnitedStates"}] -> 1,
Entity["AdministrativeDivision", {"California", "UnitedStates"}] -> 0,
Entity["AdministrativeDivision", {"Connecticut", "UnitedStates"}] -> 2,
Entity["AdministrativeDivision", {"Illinois", "UnitedStates"}] -> 3,
Entity["AdministrativeDivision", {"Maryland", "UnitedStates"}] -> 3,
Entity["AdministrativeDivision", {"Massachusetts", "UnitedStates"}] -> 3,
Entity["AdministrativeDivision", {"Montana", "UnitedStates"}] -> 0,
Entity["AdministrativeDivision", {"NewYork", "UnitedStates"}] -> 0,
Entity["AdministrativeDivision", {"NewJersey", "UnitedStates"}] -> 1,
Entity["AdministrativeDivision", {"Ohio", "UnitedStates"}] -> 1,
Entity["AdministrativeDivision", {"RhodeIsland", "UnitedStates"}] -> 2,
Entity["AdministrativeDivision", {"Texas", "UnitedStates"}] -> 0,
Entity["AdministrativeDivision", {"WestVirginia", "UnitedStates"}] -> 0
}, ColorFunction -> f]
With ColorRules
, Mathematica ignores the rules and with ColorFunction
Mathematica gives five instances of the error 0 is not a Graphics primitive or directive
. I'm using Mathematica 10.4.1.0 on OS X El Capitan.
GeoRegionValuePlot[{Entity["AdministrativeDivision", {"Texas", "UnitedStates"}] -> 0, Entity["AdministrativeDivision", {"WestVirginia", "UnitedStates"}] -> 0}, ColorRules -> {0 -> White, 1 -> Blue, 2 -> Orange, 3 -> Red}]
Note that this failure happens when two states are supposed to have the same corresponding color. $\endgroup$ColorFunction
? $\endgroup$ColorFunctionScaling -> False
. (N.B. can somebody with access to multiple versions add the customary header to localize this bug?) $\endgroup$