8

I'm struggling to find a way to change the default background color of a state, say the Netherlands, when using GeoBubbleChart.

When using GeoGraphics this is pretty easy. For example,

GeoGraphics[{
  EdgeForm[Black],
  FaceForm[Black],
  Polygon[GeoVariant[Entity["Country", "Belgium"], "PrincipalArea"]],
  Polygon[
   GeoVariant[Entity["Country", "Netherlands"], "PrincipalArea"]],
  Polygon[
   GeoVariant[Entity["Country", "Luxembourg"], "PrincipalArea"]]},
 GeoScaleBar -> "Metric",
 ImageSize -> Full,
 GeoBackground -> None,
 GeoRange -> {{49, 53.6}, {2, 7.5}}
 ] 

However, how to obtain the same result with GeoBubbleChart?

Daniel Rosencat
  • 375
  • 1
  • 4

3 Answers3

7

Carl's answer is most likely what you are looking for as it limits what is in the background. But, if you are interested in changing how the background countries look, I would suggest using one of the variants of GeoStyling["CountryBorders"]. For example,

d = {Entity["Country", "Belgium"] -> Quantity[11429336, "People"], 
   Entity["Country", "Netherlands"] -> Quantity[17035938, "People"], 
   Entity["Country", "Luxembourg"] -> Quantity[583455, "People"]};

GeoBubbleChart[d,
 GeoBackground -> GeoStyling[
   {"CountryBorders", "Land" -> Gray, "Ocean" -> White, "Border" -> Black}],
 GeoRange -> GeoGroup[d[[All, 1]]]
]

enter image description here

The additional options also apply to "Coastlines", too.

rcollyer
  • 33,976
  • 7
  • 92
  • 191
6

The easiest way is to use Show to combine the two:

d = {Entity["Country", "Belgium"] -> Quantity[11429336, "People"], 
   Entity["Country", "Netherlands"] -> Quantity[17035938, "People"], 
   Entity["Country", "Luxembourg"] -> Quantity[583455, "People"]};

Show[
 GeoGraphics[{EdgeForm[Black], FaceForm[Black], 
   Polygon[GeoVariant[Entity["Country", "Belgium"], "PrincipalArea"]],
    Polygon[
    GeoVariant[Entity["Country", "Netherlands"], "PrincipalArea"]], 
   Polygon[GeoVariant[Entity["Country", "Luxembourg"], 
     "PrincipalArea"]]}, GeoScaleBar -> "Metric"],
 GeoBubbleChart[d, GeoBackground -> None, 
  GeoRange -> {{49, 53.6}, {2, 7.5}}]
 ]

enter image description here

Carl Lange
  • 13,065
  • 1
  • 36
  • 70
5
countries = Entity["Country", #] & /@ {"Netherlands", "Belgium", "Luxembourg"};
populations = EntityValue[countries, "Population"];

We can also use GeoRegionValuePlot to style individual country polygons

grvp = GeoRegionValuePlot[Thread[countries -> Range[Length@countries]], 
   GeoRange -> {{49, 53.6}, {2, 7.5}}, 
   ColorFunction -> (Opacity[.5, ColorData[97][#]] &), 
   ColorFunctionScaling -> False, PlotLegends -> None];

and Show grvp with GeoBubbleChart using the option GeoBackground -> None:

Show[grvp, 
 GeoBubbleChart[Thread[countries -> populations], 
  ChartBaseStyle -> Opacity[1], ColorFunction -> "Rainbow", 
  GeoRange -> {{49, 53.6}, {2, 7.5}}, GeoBackground -> None], 
 ImageSize -> Medium]

enter image description here

Alternatively, we can use Image @ grvp with the option GeoBackground:

GeoBubbleChart[Thread[countries -> populations], 
 ChartBaseStyle -> Opacity[1], ColorFunction -> "Rainbow", 
 GeoRange -> {{49, 53.6}, {2, 7.5}}, 
 GeoBackground -> {"Image", Image @ grvp}]

enter image description here

kglr
  • 394,356
  • 18
  • 477
  • 896