Density Plot by Season

Density Plot by Season#

Compare how a variable’s distribution shifts across seasons using overlaid density plots.

Goal

Compare the temperature distribution of Flat A across the four seasons. This reveals how indoor temperatures shift between winter and summer and whether the building maintains consistent conditions year-round.

Data Basis

Dataset: flatTempHum.csv — Hourly indoor temperature and humidity measurements.
Columns used: time, FlatA_Temp
Time range: October 2018 – September 2020
Library: pyedautils.plots.plot_density_seasons — expects a 2-column DataFrame (timestamp column + value column).

Data Preparation#

import pandas as pd

url = "https://raw.githubusercontent.com/retomarek/edap/main/edap/sampleData/flatTempHum.csv"
df = pd.read_csv(url, sep=";", usecols=["time", "FlatA_Temp"])
df["time"] = pd.to_datetime(df["time"])
df.head()
time FlatA_Temp
0 2018-10-03 00:00:00 24.43
1 2018-10-03 01:00:00 24.40
2 2018-10-03 02:00:00 24.40
3 2018-10-03 03:00:00 24.40
4 2018-10-03 04:00:00 24.40

Visualization#

from pyedautils.plots import plot_density_seasons

fig = plot_density_seasons(
    df,
    title="Temperature Density by Season",
    xlab="Temperature [°C]",
)
fig.show()
Customization

You can pass a colors parameter to plot_density_seasons() to override the default season colors (season names Winter, Spring, Summer, Fall). For example:

fig = plot_density_seasons(
    df,
    title="Temperature Density by Season",
    xlab="Temperature [°C]",
    colors={"Winter": "blue", "Spring": "green", "Summer": "red", "Fall": "orange"},
)