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 with 4 categories

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]

enter image description here

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

  • 1
    $\begingroup$ you can also do: GeoListPlot[data, PlotStyle->(Opacity[.6,ColorData["SunsetColors"]@#]&/@Subdivide[0,1,Length[data]-1])] $\endgroup$ – kglr Sep 14 '19 at 12:57
  • $\begingroup$ In version this is fixed. But I still find the workaround useful $\endgroup$ – 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.


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


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


Mathematica graphics

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.

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

Mathematica graphics

Hope this helps.

  • $\begingroup$ 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. . $\endgroup$ – FredrikD Sep 14 '19 at 14:34
  • $\begingroup$ 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? $\endgroup$ – sunt05 Jul 4 at 22:36

The problem is due to the fact that the internal function System`GeoPlotsDump`defaultPlotStyle[] 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[{System`GeoPlotsDump`defaultPlotStyle = myDefaultPlotStyle[61]},

plot example 1

Block[{System`GeoPlotsDump`defaultPlotStyle = myDefaultPlotStyle[97]},
      GeoListPlot[List /@ Flatten[data]]]

plot example 2

  • 1
    $\begingroup$ Clever, I didn't know you could do this. $\endgroup$ – Carl Lange Sep 15 '19 at 9:48
  • $\begingroup$ 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. $\endgroup$ – FredrikD Sep 15 '19 at 11:09

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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