Population Pyramid
Population Pyramid
A population pyramid.
Usage
from dataviz_mojo import population_pyramid
from dataviz_mojo.plot 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]
var c = population_pyramid(age_bands, male, female, left_name="Male", right_name="Female")
save(c, "docs/src/examples/out_population_pyramid.svg")Args:
categories: One row of two mirrored bars per entry, top to bottom.left_values: Each row’s left-side magnitude, non-negative.right_values: Each row’s right-side magnitude, non-negative.left_name: Legend label for the left side; left empty (the default), falls back to “Left” at render time.right_name: Legend label for the right side; left empty (the default), falls back to “Right” at render time.theme: Full styling knobs beyond this function’s own parameters (colors, margins, fonts, gridlines, …) – seeTheme’s docstring.width: Pixel width of the returnedPlot(.size()).height: Pixel height of the returnedPlot(.size()).title: The chart’s title, shown above the plot.subtitle: A secondary line shown under the title.x_title: The x-axis caption.y_title: The y-axis caption.