8
$\begingroup$

Version 11 introduced GeoHistogram. It creates bins that align the edges with certain shapes. DensityHistogram can also use different shapes but its bins remain rectangular so that the shapes do no align.

Is there a way to get DensityHistogram to bin over the shape regions as GeoHistogram does? I suppose I could workout some transformation to geo-coordinates and use GeoHistogram but I'm hoping there is a means to avoid this hackery.

data = CityData[{All, "Iceland"}];

With "Hexagon"

GeoHistogram[data, ColorFunction -> "DeepSeaColors", GeoBackground -> None]

Mathematica graphics

DensityHistogram[EntityValue[data, {"Longitude", "Latitude"}], 
 ColorFunction -> "DeepSeaColors", 
 ChartElementFunction -> ChartElementDataFunction["Bubble", "Shape" -> "Hexagon"]]

Mathematica graphics

With "Triangle"

GeoHistogram[data, "Triangle", ColorFunction -> "DeepSeaColors", 
 GeoBackground -> None]

Mathematica graphics

DensityHistogram[EntityValue[data, {"Longitude", "Latitude"}], 
 ColorFunction -> "DeepSeaColors", 
 ChartElementFunction -> 
  ChartElementDataFunction["Bubble", "Shape" -> "Triangle"]]

Mathematica graphics

$\endgroup$
  • 1
    $\begingroup$ If you decide to implement it yourself, this may be helpful. $\endgroup$ – Szabolcs Aug 22 '16 at 9:30
  • $\begingroup$ @Szabolcs Looks as if you've done a bit of the heavy lifting already. $\endgroup$ – Edmund Aug 22 '16 at 9:46

Your Answer

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

Browse other questions tagged or ask your own question.