A horizontal bar divided into stripes with colors ranging from white to shades of blue and shades of red. There is a clear tendency of shades of blue on the left side of the bar, and shades of red on the right side of the bar.

Earth’s temperatures are rising and nothing shows this in a simpler, more approachable graphic than the “Warming Stripes”. Introduced by Prof. Ed Hawkins they show the temperatures either for the global average or for your region as colored bars from blue to red for the last 170 years, available at #ShowYourStripes.

The stripes have since become the logo of the Scientists for Future. Here is how you can recreate this yourself using Matplotlib.

We are going to use the HadCRUT4 dataset, published by the Met Office. It uses combined sea and land surface temperatures. The dataset used for the warming stripes is the annual global average.

First, let’s import everything we are going to use. The plot will consist of a bar for each year, colored using a custom color map.

import matplotlib.pyplot as plt
from matplotlib.patches import Rectangle
from matplotlib.collections import PatchCollection
from matplotlib.colors import ListedColormap
import pandas as pd

Then we define our time limits, our reference period for the neutral color and the range around it for maximum saturation.

FIRST = 1850
LAST = 2018  # inclusive

# Reference period for the center of the color scale
LIM = 0.7  # degrees

Here we use pandas to read the fixed width text file, only the first two columns, which are the year and the deviation from the mean from 1961 to 1990.

# data from
# https://www.metoffice.gov.uk/hadobs/hadcrut4/data/current/time_series/HadCRUT.
df = pd.read_fwf(
    usecols=(0, 1),
    names=["year", "anomaly"],

anomaly = df.loc[FIRST:LAST, "anomaly"].dropna()
reference = anomaly.loc[FIRST_REFERENCE:LAST_REFERENCE].mean()

This is our custom colormap, we could also use one of the colormaps that come with matplotlib, e.g. coolwarm or RdBu.

# the colors in this colormap come from http://colorbrewer2.org
# the 8 more saturated colors from the 9 blues / 9 reds
cmap = ListedColormap(

We create a figure with a single axes object that fills the full area of the figure and does not have any axis ticks or labels.

fig = plt.figure(figsize=(10, 1))

ax = fig.add_axes([0, 0, 1, 1])

Finally, we create bars for each year, assign the data, colormap and color limits and add it to the axes.

# create a collection with a rectangle for each year
col = PatchCollection([Rectangle((y, 0), 1, 1) for y in range(FIRST, LAST + 1)])

# set data, colormap and color limits
col.set_clim(reference - LIM, reference + LIM)

Make sure the axes limits are correct and save the figure.

ax.set_ylim(0, 1)
ax.set_xlim(FIRST, LAST + 1)


Warming Stripes