Code to make treemap

Earlier this week I posted about this treemap I made. (Interactive version) Today, I have placed the code to produce this treemap in a Codeberg repo. It’s not the most beautiful code in the world. (If I were really ambitious, I’d turn it into a proper library.)

This is America

This is a treemap of every county (or county equivalent) in the United States, where the area of each rectangle is proportional to the population of the corresponding county. Counties that are part of the same core-based statistical area are grouped together. (These have a thicker green border.) Moreover, core-based statistical areas that belong to the same combined statistical area are grouped together. (CSAs have an even-thicker red border.) For example, the red rectangle in the upper-left corner represents the New York-Newark, NY-NJ-CT-PA CSA: