Heatmap Calendar#
This example demonstrates how to use plot_heatmap_calendar to visualize
daily aggregated energy consumption in a calendar layout.
Each cell represents one day. Rows are weekdays (Mon–Sun), columns are calendar weeks, and each year is shown as a separate row.
All plots are interactive — hover to see exact date and value.
# 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_calendar
fig = plot_heatmap_calendar(
data=df,
title="Calendar Plot Energy Consumption",
ylab="Energy Consumption (Wh/d)",
)
fig.show()
Customization#
You can change the color scale:
fig = plot_heatmap_calendar(
data=df,
title="Calendar Heatmap (Viridis)",
ylab="Energy Consumption (Wh/d)",
colorscale="Viridis",
)
fig.show()