Bangladesh Population by Religion - Python Code Explanation

Goal of the Script

This Python script creates a publication-quality stacked area chart showing population trends by religion in Bangladesh from the 1951 through 2022 censuses. The chart displays population counts in millions and highlights changes among major religious groups over time.

Code Description

The script uses matplotlib to create the visualization and pathlib to manage output file locations.

Historical census population values are stored as Python lists for:

Data Preparation

The script combines Buddhist, Christian, and Other religion categories into a single Others category. This provides a simplified comparison between Muslim, Hindu, and other religious populations.

Chart Creation

The program creates a stacked area chart using matplotlib. The chart:

Summary Information

The chart includes a summary table comparing population values for 1951 and 2022. The table displays Muslim, Hindu, Others, and Total population counts in millions.

Source and Interpretation

The visualization uses Bangladesh Population Census data from 1951–2022. The "Others" category combines Buddhist, Christian, and other religion categories.

Output Files

The script saves the completed chart in two formats:

Summary

This script demonstrates a complete Python data visualization workflow: preparing historical census data, creating a stacked area chart, adding summary tables and annotations, and exporting publication-quality graphics for reports and presentations.