Skip to content

Note

Click here to download the full example code

Shells and Cores

A proportional cartogram of poverty in the United States.

Create cartogram by shrinking geometries to create concentric shells.

import carto_flow.data as examples
from carto_flow.proportional_cartogram import partition_geometries
from carto_flow.proportional_cartogram.visualization import plot_partitions

us_states = examples.load_us_census(population=True, race=True, poverty=True, simplify=1000)

partition = partition_geometries(us_states, columns=["Below Poverty Level %", "Above Poverty Level %"], method="shrink")

plot = plot_partitions(
    partition,
    color_by="category",
    edgecolor="white",
    palette={"Below Poverty Level %": "darkgreen", "Above Poverty Level %": "#cceecc"},
)

_ = plot.ax.axis("off")
_ = plot.ax.set_title("Poverty in the US")

Poverty in the US

Total running time of the script: ( 0 minutes 8.403 seconds)

Download Python source code: plot_proportional.py

Download Jupyter notebook: plot_proportional.ipynb

Gallery generated by mkdocs-gallery