Wolfram Function Repository
Instant-use add-on functions for the Wolfram Language
Function Repository Resource:
Create a non-overlapping cartogram type with visual equalization, partial topology preservation and no shape preservation
| ResourceFunction["DorlingCartogram"][loc→val] generates a graphic of non-overlapping circles for initial locations loc with areas corresponding to val. | |
| ResourceFunction["DorlingCartogram"][{loc1→val1 ,loc2→val2,…}] generates a graphic of non-overlapping circles with initial locations loci with areas corresponding to vali. | |
| ResourceFunction["DorlingCartogram"][spec,n] generates a graphic of non-overlapping regular n-sided polygons with initial locations and values as given by spec. | 
Define an example dataset of random values:
| In[1]:= | ![data = Thread[
   Rule[RandomReal[{0, 100}, {10, 2}], RandomReal[10^6, 10]]];](https://www.wolframcloud.com/obj/resourcesystem/images/0ae/0aefb6c3-e358-401f-9b61-05cc612fe40c/38c17ae4dc7a101e.png) | 
Create a cartogram with circles:
| In[2]:= | ![ResourceFunction["DorlingCartogram"][data]](https://www.wolframcloud.com/obj/resourcesystem/images/0ae/0aefb6c3-e358-401f-9b61-05cc612fe40c/1ec935b484d7dcff.png) | 
| Out[2]= |  | 
Create a cartogram for the 250 most populous cities in the United States:
| In[3]:= | ![ResourceFunction["DorlingCartogram"][
 EntityValue[
   EntityClass[
    "City", {"Country" -> Entity["Country", "UnitedStates"], "Population" -> TakeLargest[100]}], "Entities"] -> "Population"]](https://www.wolframcloud.com/obj/resourcesystem/images/0ae/0aefb6c3-e358-401f-9b61-05cc612fe40c/7ef650bd7b3b4516.png) | 
| Out[3]= |  | 
Create a non-overlapping cartogram for the 250 most populous cities in the United Kingdom:
| In[4]:= | ![ResourceFunction["DorlingCartogram"][
 EntityValue[
   EntityClass[
    "City", {"Country" -> Entity["Country", "UnitedKingdom"], "Population" -> TakeLargest[250]}], "Entities"] -> "Population", ColorFunction -> "Aquamarine"]](https://www.wolframcloud.com/obj/resourcesystem/images/0ae/0aefb6c3-e358-401f-9b61-05cc612fe40c/1b76c4d57f4cdb3a.png) | 
| Out[4]= |  | 
Create a non-overlapping cartogram for the level-2 administrative division in the United Kingdom:
| In[5]:= | ![UKadd1 = EntityList[
   Entity["AdministrativeDivision", {EntityProperty[
       "AdministrativeDivision", "ParentRegion"] -> Entity["Country", "UnitedKingdom"]}]];](https://www.wolframcloud.com/obj/resourcesystem/images/0ae/0aefb6c3-e358-401f-9b61-05cc612fe40c/2e0420ed43fc7817.png) | 
| In[6]:= | ![UKadd2 = Flatten[EntityList[
      Entity["AdministrativeDivision", {EntityProperty[
          "AdministrativeDivision", "ParentRegion"] -> #}]] & /@ UKadd1];](https://www.wolframcloud.com/obj/resourcesystem/images/0ae/0aefb6c3-e358-401f-9b61-05cc612fe40c/44e1361ea541b7fa.png) | 
| In[7]:= | ![ResourceFunction["DorlingCartogram"][
 Style[UKadd2 -> "Population", Directive[EdgeForm[], FaceForm[Orange]]], "Method" -> "AdjustedStepSize"]](https://www.wolframcloud.com/obj/resourcesystem/images/0ae/0aefb6c3-e358-401f-9b61-05cc612fe40c/2da2df3262c88264.png) | 
| Out[7]= |  | 
Create a cartogram for the 250 most populous cities in India:
| In[8]:= | ![ResourceFunction["DorlingCartogram"][
 EntityValue[
   EntityClass[
    "City", {"Country" -> Entity["Country", "India"], "Population" -> TakeLargest[250]}], "Entities"] -> "Population", "Square", ColorFunction -> "Rainbow"]](https://www.wolframcloud.com/obj/resourcesystem/images/0ae/0aefb6c3-e358-401f-9b61-05cc612fe40c/077018ec0f40f52b.png) | 
| Out[8]= |  | 
Create a cartogram for the 250 most populous cities in Poland:
| In[9]:= | ![ResourceFunction["DorlingCartogram"][
 EntityValue[
   EntityClass[
    "City", {"Country" -> Entity["Country", "Poland"], "Population" -> TakeLargest[250]}], "Entities"] -> "Population", 5, ColorFunction -> Function[{z}, Hue[Log[z]]], ColorFunctionScaling -> False]](https://www.wolframcloud.com/obj/resourcesystem/images/0ae/0aefb6c3-e358-401f-9b61-05cc612fe40c/24276defe88c8feb.png) | 
| Out[9]= |  | 
Define an example dataset:
| In[10]:= | ![data = Thread[
   Rule[RandomReal[{0, 100}, {10, 2}], RandomReal[10^6, 10]]];](https://www.wolframcloud.com/obj/resourcesystem/images/0ae/0aefb6c3-e358-401f-9b61-05cc612fe40c/51f2bfbe1955ab34.png) | 
The default method "FixedStepSize" employs a step size on the magnitude of scale, which enables a quick calculation of many iterations:
| In[11]:= | ![ResourceFunction["DorlingCartogram"][data, ImageSize -> 100]](https://www.wolframcloud.com/obj/resourcesystem/images/0ae/0aefb6c3-e358-401f-9b61-05cc612fe40c/49f89aead4407063.png) | 
| Out[11]= |  | 
The default of the maximum number of potential iterations is coupled to the method. The computation can finish earlier if no shapes overlap anymore.
Define an example dataset:
| In[12]:= | ![data = Thread[
   Rule[RandomReal[{0, 1000}, {100, 2}], RandomReal[10^6, 100]]];](https://www.wolframcloud.com/obj/resourcesystem/images/0ae/0aefb6c3-e358-401f-9b61-05cc612fe40c/0b7fdfb1ef507467.png) | 
MaxIterations→0 returns the initial configuration:
| In[13]:= | ![ResourceFunction["DorlingCartogram"][data, MaxIterations -> 0]](https://www.wolframcloud.com/obj/resourcesystem/images/0ae/0aefb6c3-e358-401f-9b61-05cc612fe40c/439b7e9980fca0b9.png) | 
| Out[13]= |  | 
Supported methods are "FixedStepSize" and "AdjustedStepSize".
Define an example dataset:
| In[14]:= | ![data = Thread[
   Rule[RandomReal[{0, 1000}, {100, 2}], RandomReal[10^6, 100]]];](https://www.wolframcloud.com/obj/resourcesystem/images/0ae/0aefb6c3-e358-401f-9b61-05cc612fe40c/3909b5ee699c4531.png) | 
The default method "FixedStepSize" employs a step size on the magnitude of scale, which enables a quick calculation of many iterations:
| In[15]:= | ![ResourceFunction["DorlingCartogram"][data, Method -> "FixedStepSize"]](https://www.wolframcloud.com/obj/resourcesystem/images/0ae/0aefb6c3-e358-401f-9b61-05cc612fe40c/4132fc6213a7973a.png) | 
| Out[15]= |  | 
In the "AdjustedStepSize" method, the step size is adjusted after each step, which leads to good visual results after just a few iterations, but often slows overall convergence:
| In[16]:= | ![ResourceFunction["DorlingCartogram"][data, Method -> "AdjustedStepSize"]](https://www.wolframcloud.com/obj/resourcesystem/images/0ae/0aefb6c3-e358-401f-9b61-05cc612fe40c/26d7b33bdf417571.png) | 
| Out[16]= |  | 
Define an example dataset:
| In[17]:= | ![data = Thread[
   Rule[RandomReal[{0, 1000}, {100, 2}], RandomReal[10^6, 100]]];](https://www.wolframcloud.com/obj/resourcesystem/images/0ae/0aefb6c3-e358-401f-9b61-05cc612fe40c/39e03a7cd150117e.png) | 
Rotate the regular triangle shape by 30 degrees counterclockwise:
| In[18]:= | ![ResourceFunction["DorlingCartogram"][data, 3, "Rotate" -> (30 Degree)]](https://www.wolframcloud.com/obj/resourcesystem/images/0ae/0aefb6c3-e358-401f-9b61-05cc612fe40c/3d8ab52780fe7400.png) | 
| Out[18]= |  | 
Define an example dataset:
| In[19]:= | ![data = Thread[
   Rule[RandomReal[{0, 1000}, {100, 2}], RandomReal[10^6, 100]]];](https://www.wolframcloud.com/obj/resourcesystem/images/0ae/0aefb6c3-e358-401f-9b61-05cc612fe40c/57fd26a6351f077c.png) | 
The default scale is determined such that approximately a quarter of the available space is filled:
| In[20]:= | ![ResourceFunction["DorlingCartogram"][data]](https://www.wolframcloud.com/obj/resourcesystem/images/0ae/0aefb6c3-e358-401f-9b61-05cc612fe40c/38c6fc9df0b1011d.png) | 
| Out[20]= |  | 
Use a custom scale:
| In[21]:= | ![ResourceFunction["DorlingCartogram"][data, "Scale" -> 0.02]](https://www.wolframcloud.com/obj/resourcesystem/images/0ae/0aefb6c3-e358-401f-9b61-05cc612fe40c/1cfb28cd90f2b869.png) | 
| Out[21]= |  | 
This work is licensed under a Creative Commons Attribution 4.0 International License