THE SNOWS OF YESTERYEAR

SNOW DEPTH IN OSLO FROM 2012 TO 2020

Small multiples weather chart with Pandas and Matplotlib.


I moved to Oslo in 2012, and I've always found the amount of snow here staggering compared to where I lived before! But exactly how much snow has there been? I downloaded data from Norsk Klimaservicesenter (Norwegian Centre for Climate Services / NCCS) and made a plot to find out how the winters have really looked like in Oslo over the last eight years.


In [1]:
import pandas as pd
import matplotlib as mpl
from matplotlib import pyplot as plt
import seaborn as sns
import datetime as dt
import matplotlib.dates as mdates
import matplotlib.ticker as ticker
from matplotlib.dates import DateFormatter
In [2]:
df = pd.read_csv("snow-in-oslo.csv", delimiter=',')
df.head(2)
Out[2]:
name station date surface_snow_thickness winter
0 Oslo - Blindern SN18700 01.09.2012 0 12to13season
1 Oslo - Blindern SN18700 02.09.2012 0 12to13season
In [4]:
mpl.rcParams["figure.dpi"]= 300
mpl.rcParams["font.family"] = "Courier New"
mpl.rcParams["font.size"] = "3"
mpl.rcParams["font.weight"] = "bold"

fig = plt.figure(figsize=(8, 4))

season = df.groupby("winter")

subplot = 0

for group in season.groups:

    subplot += 1

    pltx = season.get_group(group)["date"]
    plty = season.get_group(group)["surface_snow_thickness"]

    ax = fig.add_subplot(4, 2, subplot)

    plt.subplots_adjust(hspace=0.85)
    sns.set_style({"axes.facecolor": "lightblue", "figure.facecolor": "lightblue"})
    ax.xaxis.set_major_locator(ticker.LinearLocator(numticks=10))
    ax.yaxis.set_major_locator(ticker.LinearLocator(numticks=7))
    ax.spines["top"].set_visible(False)
    ax.spines["right"].set_visible(False)
    ax.spines["bottom"].set_visible(False)
    ax.spines["left"].set_visible(False)
    if subplot == 1:
        ax.set_ylabel("Snow depth (cm)", size=5, fontweight="bold", color="#333333")
    ax.tick_params(axis="x", size=2, color="white")
    ax.tick_params(axis="y", size=2, color="white")
    plt.ylim(0, 60)

    plt.fill_between(pltx, plty, color="white")
    plt.plot(pltx, plty, color="none")