6
$\begingroup$

I have a GeoGraphics where I am using Scaled in PointSize to include size information. I want to Inset a PointLegend that describes the sizes of the points.

Outside of GeoGraphics I can do this by specifying the sizes directly using the LegendMarkerSize option. For example:

PointLegend[
 ConstantArray[Black, 4], {"Size1", "Size2", "Size3", "Size4"},
 LegendLabel -> "Info",
 LegendMarkerSize -> Range[12, 20, 2],
 LegendFunction -> "Panel"]

Mathematica graphics

However, when I try this method with Scaled and Inset the points in the legend do not scale to the expected size.

GeoGraphics[
 MapIndexed[{PointSize[Scaled[0.02 First@#2]], 
     Point@GeoPosition@#1} &]@({35, -95} + {#, -#} & /@ Range[.1, .4, .1]),
 Epilog -> {
    Inset[
    PointLegend[
     ConstantArray[Black, 4], {"Size1", "Size2", "Size3", "Size4"},
     LegendLabel -> "Info",
     LegendMarkerSize -> Scaled /@ Range[.02, .08, .02],
     LegendFunction -> "Panel"]]}
 ]

Mathematica graphics

How do I get the legend to display points at the correct scaled sizes?

$\endgroup$

1 Answer 1

2
$\begingroup$

WRI provided the below workaround as it seems GeoGraphics does not yet have full legend support.

Manipulate[
 im = GeoGraphics[
   MapIndexed[{PointSize[Scaled[0.02 First@#2]], 
       Point@GeoPosition@#1} &]@({35, -95} + {#, -#} & /@ Range[.1, .4, .1]),
   Epilog -> {
     Inset[
      PointLegend[
       ConstantArray[Black, 4], {"Size1", "Size2", "Size3", "Size4"},
       LegendLabel -> "Info",
       LegendMarkerSize -> scale2 scaling  Range[.02, .08, .02],
       LegendFunction -> "Panel"],
      {Left, Bottom}, {Left, Bottom}]},
   ImageSize -> scaling 350],
 {scaling, 1, 2}, {{scale2, 500}, 100, 1000}]

Mathematica graphics

This allows you to dynamically adjust LegendMarkerSize by eye until the size of the points on the map match the size of the points in the legend. im is updated to contain the GeoGraphics. It is not very useful for automation but will work for one off plots. Fingers are crossed for full legend support in future.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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