Using IPCC Color Palettes

pyam supports the use of explicit IPCC AR5 and AR6 color palettes by providing the RCP and/or SSP of interest via the pyam.run_control() feature.

[1]:
import pandas as pd
import pyam

The full list of the IPCC color palette colors avaialable in pyam can be retrieved by the following code.

[2]:
colors = pyam.plotting.PYAM_COLORS
pd.DataFrame({'name': list(colors.keys()), 'color': list(colors.values())})
[2]:
name color
0 AR6-SSP1 #1e9583
1 AR6-SSP2 #4576be
2 AR6-SSP3 #f11111
3 AR6-SSP4 #e78731
4 AR6-SSP5 #8036a7
5 AR6-SSP1-1.9 #00a9cf
6 AR6-SSP1-2.6 #003466
7 AR6-SSP2-4.5 #f69320
8 AR6-SSP3-7.0 #df0000
9 AR6-SSP3-LowNTCF #e61d25
10 AR6-SSP4-3.4 #2274ae
11 AR6-SSP4-6.0 #b0724e
12 AR6-SSP5-3.4-OS #92397a
13 AR6-SSP5-8.5 #980002
14 AR6-RCP-2.6 #003466
15 AR6-RCP-4.5 #709fcc
16 AR6-RCP-6.0 #c37900
17 AR6-RCP-8.5 #980002
18 AR5-RCP-2.6 #0000FF
19 AR5-RCP-4.5 #79BCFF
20 AR5-RCP-6.0 #FF822D
21 AR5-RCP-8.5 #FF0000

Display scenario data with default colours

We use the scenario ensemble from the first-steps tutorial (here on GitHub and on read the docs). Let’s pull out two example scenarios (implemented by multiple modelling frameworks each) and plot them with the default color scheme.

[3]:
scenarios = ['CD-LINKS_NoPolicy', 'CD-LINKS_NPi2020_400']

df = (
    pyam.IamDataFrame(data='tutorial_data.csv')
    .filter(variable='Emissions|CO2', region='World', scenario=scenarios)
)

df.plot(color='scenario')
pyam - INFO: Running in a notebook, setting up a basic logging at level INFO
pyam.core - INFO: Reading file tutorial_data.csv
[3]:
<AxesSubplot:title={'center':'region: World - variable: Emissions|CO2'}, xlabel='Year', ylabel='Mt CO2/yr'>
../_images/tutorials_ipcc_colors_5_2.png

As an example, we assume that each of these two sets of scenarios correspond to categorizations in the AR6 context. We can utilize the specific colors by following two steps:

  1. Update pyam.run_control() telling it which scenario name maps to which AR6 color

  2. Call line_plot using that color mapping

Updating the run control

We need to tell pyam that whenever it sees a certain scenario name, it should use a specific color from the IPCC palette.

[4]:
color_map = {
    'CD-LINKS_NPi2020_400': 'AR6-SSP2-4.5',
    'CD-LINKS_NoPolicy': 'AR6-SSP5-8.5',
}

pyam.run_control().update({'color': {'scenario': color_map}})

The illustration above is implemented directly in Python code, but it also works by specifying the desired mapping in a yaml configuration file and loading that file into run_control().

Use the new colors

Now, it’s as simple as calling the plot function again!

[5]:
df.plot(color='scenario')
[5]:
<AxesSubplot:title={'center':'region: World - variable: Emissions|CO2'}, xlabel='Year', ylabel='Mt CO2/yr'>
../_images/tutorials_ipcc_colors_11_1.png