Stacked bar charts¶
# sphinx_gallery_thumbnail_number = 4
Read in tutorial data and show a summary¶
This gallery uses the scenario data from the first-steps tutorial.
If you haven’t cloned the pyam GitHub repository to your machine, you can download the file from https://github.com/IAMconsortium/pyam/tree/main/doc/source/tutorials.
Make sure to place the data file in the same folder as this script/notebook.
<class 'pyam.core.IamDataFrame'> Index: * model : AIM/CGE 2.1, GENeSYS-MOD 1.0, ... WITCH-GLOBIOM 4.4 (8) * scenario : 1.0, CD-LINKS_INDCi, CD-LINKS_NPi, ... Faster Transition Scenario (8) Timeseries data coordinates: region : R5ASIA, R5LAM, R5MAF, R5OECD90+EU, R5REF, R5ROWO, World (7) variable : ... (6) unit : EJ/yr, Mt CO2/yr, °C (3) year : 2010, 2020, 2030, 2040, 2050, 2060, 2070, 2080, ... 2100 (10) Meta indicators: exclude (bool) False (1)
Show stacked bar chart by categories¶
First, we generate a simple stacked bar chart of all components of primary energy supply for one scenario.
that the final plot looks nice and tidy.
Flip the direction of a stacked bar chart¶
We can flip that round for a horizontal chart.
Show stacked bar chart by regions¶
We don’t just have to plot subcategories of variables, any data or meta indicators from the IamDataFrame can be used. Here, we show the contribution by region to total CO2 emissions.
Add indicators to show net values¶
Sometimes, stacked bar charts have negative entries. In that case, it helps to add a line showing the net value.
Total running time of the script: ( 0 minutes 1.039 seconds)