# GeoListPlot - Workaround for distinct coloring of categories - improvement?

GeoListPlot supports multiple lists of locations but once the number of lists exceeds 3, the coloring function for the categories starts to recycle the colors. For example, adding a list to the example of the documentation produces the map below

data= {{Entity["Country", "Bulgaria"], Entity["Country", "Greece"]}, {Entity["Country", "Albania"], Entity["Country", "Romania"]},{Entity["Country", "Turkey"], Entity["Country", "Lebanon"]}, {Entity["Country", "Israel"], Entity["Country", "Syria"]}};

GeoListPlot[data]


This was reported some time ago to Wolfram (CASE: 41535576) but it still an issue in version 12.

My current work around is to define a list of colors and to use the Directive function. An example:

colors = Table[
ColorData["SunsetColors"][i], {i, 0, 1, 1/((Length@data - 1))}];
plotStylesDef = Directive[#, Opacity[0.6]] & /@ colors;
GeoListPlot[data, GeoLabels -> None, PlotLegends -> Automatic,
PlotStyle -> plotStylesDef]


My question is: how can this workaround be improved? (More robust, overload the original function, better selection of ColorData..)

• you can also do: GeoListPlot[data, PlotStyle->(Opacity[.6,ColorData["SunsetColors"]@#]&/@Subdivide[0,1,Length[data]-1])] – kglr Sep 14 '19 at 12:57
• In version 12.2.0.0 this is fixed. But I still find the workaround useful – FredrikD Feb 12 at 13:58

You may use ColorDatawith an "Indexed" color scheme. These can be viewed in from the menu Palettes | Color Schemes palette. They can be referenced by their index or their name.

Both

GeoListPlot[data,
PlotStyle -> ColorData[98] /@ Range@Length@data]


and

GeoListPlot[data,
PlotStyle -> ColorData[{"Indexed", "Earth"}] /@ Range@Length@data]


give

These colour indices repeat themselves when the requested colour exceeds the numer of colours in the "ColorList" so you should pick one that has a reasonable amount in them. For schemes with more than 10 colours,

Select[Length@ColorData[#, "ColorList"] > 10 &]@ColorData["Indexed"]


However, if you are set on using a "Gradient" colour scheme then you may use Rescale.

GeoListPlot[data,
PlotStyle -> ColorData["Rainbow"] /@ Rescale@Range@Length@data]


Hope this helps.

• Brilliant w Rescale! Straightforward to add the Directive[.., Opacity[]] (...PlotStyle-> (Directive[#, 0.6]&/@(ColorData[..]@...)). The reason for that construct is for the PlotLegend's color to better match the color on the map. Also I didn't think about that search for the indexed colors with more than e.g. 10 values. . – FredrikD Sep 14 '19 at 14:34
• in v12.3, this code won't work: GeoListPlot[data, PlotStyle -> ColorData[{"Indexed", "Earth"}] /@ Range@Length@data]: all in the same colour. Seems to be a bug? – sunt05 Jul 4 at 22:36

The problem is due to the fact that the internal function SystemGeoPlotsDumpdefaultPlotStyle[] used by GeoListPlot[] is working with a somewhat limited color selection. For obvious reasons, I won't copy the definition of this internal function here; instead, let me propose a possible replacement function:

myDefaultPlotStyle[i_Integer][l_Integer] :=
Table[Directive[ColorData[i, k], EdgeForm[Directive[Thin, Opacity[0.4]]],
PointSize[Large], FaceForm[Opacity[0.5]]], {k, l}]


which uses the indexed colors supported by ColorData[]. (You can of course replace ColorData[i, k] with some other function that generates an indexed color list.)

Then, for instance,

Block[{SystemGeoPlotsDumpdefaultPlotStyle = myDefaultPlotStyle[61]},
GeoListPlot[data]]


Block[{SystemGeoPlotsDumpdefaultPlotStyle = myDefaultPlotStyle[97]},
GeoListPlot[List /@ Flatten[data]]]


• Clever, I didn't know you could do this. – Carl Lange Sep 15 '19 at 9:48
• Great, so one way WRI can fix the bug is to replace the internal function with something in line your "myDefault..." combined with making sure that the indexed colors scheme choosen have enough different values. – FredrikD Sep 15 '19 at 11:09