At My Fingertips
Warming stripes (climate change stripes) are an interesting data visualization to show with a strong visual impact how much our planet is getting warmer:
As a case study, let's try to visualize the temperature anomaly in Southern Switzerland thanks to the data collected by MeteoSwiss.
You can already find the dataset in a dictionary named temperature
, which has as a key the year and as a value the yearly average temperature recorded in the south of Switzerland
(which is an average of all the temperatures recorded by the various stations at different altitudes during daytime and nighttime).
Data refers to the period 1864-2022, including the extremes.
Try to retrieve and print the value of temperature in 2022:
The basic ingredient of warming stripes is a thin vertical stripe. A stripe is colored according to the temperature difference recorded in a given year with respect to the average value of a relatively recent period. For example, you can use the average of the period 1971-2000 as a reference, and then compute the differences.
We can use the blue and red palette picked by Ed Hawkins, the climate scientist who made this visualization popular. We collected the colors he picked and we expressed them as tuples of RGB values (between 0 and 255).
You can try to visualize the most intense red, using the components of the last tuple in the list of reds
and the function rgb_color:
All that remains is to map the temperature differences to the various colors.
There are several ways to do this: a simple one is to match each tenth of a degree Celsius (0.1
) to a color.
Finally, create the entire visualization, which is nothing more than a list of stripes one beside the other. Feel free to use the mapping strategy you prefer.
This activity has been created by LuCE Research Lab and is licensed under CC BY-SA 4.0.
Warming Stripes
PyTamaro is a project created by the Lugano Computing Education Research Lab at the Software Institute of USI
Privacy Policy • Platform Version c3a8286 (Mon, 14 Oct 2024 13:30:28 GMT)