how elemental cartograms are made


A Cartogram is a way to visualize data by distorting a map.  In our case the map is the periodic table of elements, and the area of each element is distorted by a theme of your choice.  Our approach begins by generating a periodic table as an image, where the intensity of each element is the value you gave to the element in the spreadsheet. 

  - intensity scaled ->

This image is fed into a program developed by Mark Newmann that effectively diffuses the brighter parts of the image and calculates a map of the velocities of diffusion at each point(1)We then feed in the vector positions of the perimeter of each element into this mapping, and the resulting positions make up our cartogram. 

     - velocity map ->    

From there the code has to do some  work to figure out the maximum square that can fit in each warped element, in order to take a good guess at what fontsize to use and whether the element is big enough to bother writing its full name or just its symbol.  It also adds the references, if listed in the original spreadsheet.



A nice aspect of this approach is that the periodic table is procedurally generated, so tricks like changing the names of the elements or putting the f-block beneath the other elements (a conventional sin, as far as I'm concerned), are very easy to implement. 

1.  Diffusion-based method for producing density-equalizing maps, Michael T. Gastner and M. E. J. Newman.  Published online before print May 10, 2004, doi: 10.1073/pnas.0400280101, PNAS May 18, 2004 vol. 101 no. 20 7499-7504