Population Pyramid
population_pyramid() over named columns of a dataframe_mojo DataFrame (#743). Each argument names a column instead of holding the values.
Usage
from dataviz import population_pyramid
from dataviz import save
def main() raises:
var age_bands: List[String] = ["0-9", "10-19", "20-29", "30-39", "40-49", "50-59", "60-69", "70+"]
var male: List[Float64] = [12.0, 13.0, 14.0, 12.5, 10.0, 8.5, 6.0, 4.0]
var female: List[Float64] = [11.5, 12.5, 13.5, 12.0, 10.5, 9.0, 7.0, 5.5]
# Illustrative resident counts in millions.
var c = population_pyramid(
age_bands,
male,
female,
left_name="Male",
right_name="Female",
title="Illustrative Population by Age and Sex",
x_title="Population (millions)",
y_title="Age group",
)
save(c, "docs/src/examples/out_population_pyramid.svg")See Data shapes for shared input conventions.
Args:
df: The frame to read.categories: The string column for this channel.left_values: The numeric column for this channel.right_values: The numeric column for this channel.left_name: See the list overload.right_name: See the list overload.theme: See the list overload.width: See the list overload.height: See the list overload.title: See the list overload.subtitle: See the list overload.x_title: See the list overload.y_title: See the list overload.
Related
Relevant API: population_pyramid