Heatmap Median Weeks

Heatmap Median Weeks#

This example demonstrates how to use plot_heatmap_median_weeks to visualize median energy consumption per hour, grouped by weekday and season.

Each season is shown as a separate heatmap. The y-axis shows weekdays, the x-axis shows the hour of day, and the color intensity represents the median value.

All plots are interactive — hover to see exact values.

# Configure Plotly to render as HTML (required for Jupyter Book)
import plotly.io as pio
pio.renderers.default = "notebook_connected"
import pandas as pd
from importlib import resources

# Load the bundled sample data
data_path = resources.files("pyedautils") / "data" / "ele_meter.csv"
df = pd.read_csv(data_path, sep=";")
df.head()
timestamp value
0 2015-01-01 00:00:00 40.0
1 2015-01-01 00:15:00 32.0
2 2015-01-01 00:30:00 32.0
3 2015-01-01 00:45:00 34.0
4 2015-01-01 01:00:00 34.0

Basic Usage#

from pyedautils.plots import plot_heatmap_median_weeks

fig = plot_heatmap_median_weeks(
    data=df,
    title="Electricity Meter - Heatmap Median Weeks",
    ylab="Energy [kWh/h]",
)
fig.show()

Customization#

You can change the color scale and use custom season labels:

fig = plot_heatmap_median_weeks(
    data=df,
    title="Custom Colorscale Example",
    ylab="Energy [kWh/h]",
    colorscale="Viridis",
)
fig.show()
fig = plot_heatmap_median_weeks(
    data=df,
    title="German Season Labels",
    ylab="Energie [kWh/h]",
    seasons=["Frühling", "Sommer", "Herbst", "Winter"],
)
fig.show()