The classical time series heatmap plot extended with a mean profile and daily average and peaks. This type of visualization is very informative when showing large amounts of time series data. While I mostly use it for energy data, it can easily be adapted for any other time series. The figure works best for data with a range of a few months to a few years and a resolution of a few minutes to a few hours.
Installation
The package is available on PyPI:
pip install heatmapts
Alternatively, you can install it from GitHub:
pip install git+https://github.com/markus-kreft/heatmapts.git
or simply clone this repository and work in the local directory.
Usage
The module provides the heatmapfigure function that takes a pandas Series with a timezone-aware DatetimeIndex with frequency.
This example shows how to load and prepare data from a csv file in the necessary way. This needs to be adapted depending on the format of the data at hand.
import pandas as pd
from heatmapts import heatmapfigure
# Read data
df = pd.read_csv('data.csv', index_col='Timestamp')
# Convert index to datetime and set timezone
df.index = pd.to_datetime(df.index, format='%Y-%m-%d %H:%M:%S').tz_convert('Europe/Zurich')
# Resample to 15min frequency
df = df.asfreq("15min", fill_value=pd.NA)
# Take data column and convert energy to power
series = df['Value'] * 4
fig = heatmapfigure(series, rasterized=True)
fig.savefig("plot.pdf")
Customization
The figure is designed for easy customization.
- Any additional keyword arguments are passed to pcolormesh, which is especially convenient for using a different colormap or norm or to use rasterization.
- Passing a tuple of latitude and longitude coordinates will add sunrise and sunset times to the plot.
fig = heatmapfigure(series, annotate_suntimes=(52.37, 4.90))
- Passing
Noneasdaily_labelorhourly_labelomits the respective daily overview or mean profile subplot.
fig = heatmapfigure(series, daily_label=None)
- The returned figure is subclassed from
matplotlib.figure.Figureand features additional attributes for the heatmap, colorbar, daily and hourly axes. These can be modified as any other matplotlib axis.
fig.ax_heatmap.xaxis.set_major_locator(mdates.YearLocator())
fig.ax_heatmap.xaxis.set_major_formatter(mdates.DateFormatter("%Y"))
- The figure uses its own rcParams for styling.
You can modify or overwrite the parameters on a class level.
When setting an empty rcParams dictionary, the current parameters from matplotlib (e.g., as determined by
matplotlibrc) will be used.
from heatmapts import HeatmapFigure
# Customize rc parameters
HeatmapFigure.rc_params["font.family"] = "serif"
HeatmapFigure.rc_params["font.size"] = 5
# Set empty rc parameters to use those from matplotlib
HeatmapFigure.rc_params = {}
Metadata
Release files for heatmapts 0.2.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| heatmapts-0.2.0.tar.gz | 9.3 kB | Without provenance | Details for heatmapts-0.2.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| heatmapts-0.2.0-py3-none-any.whl | Python 3 | none | any | Details for heatmapts-0.2.0-py3-none-any.whl |
Total release size: 19.9 kB
Release files / heatmapts-0.2.0.tar.gz
| Download URL | heatmapts-0.2.0.tar.gz |
|---|---|
| Size | 9.3 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
efc1ff547a703f7ac80c188b98d8c4b7956299455579df197d9fd24260ebc497
|
|
BLAKE2b-256 checksum How to use checksums |
c5d33d5f9094fe7b357a3b5947564b3652d381df5effb19b12a7ca0115ae5992
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
uv/0.11.23 {"installer":{"name":"uv","version":"0.11.23","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
|
Release files / heatmapts-0.2.0-py3-none-any.whl
| Download URL | heatmapts-0.2.0-py3-none-any.whl |
|---|---|
| Size | 10.6 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
ca230ae4d2742ec3237d4ce49edd2873412bfa877fc7f16c609ba6ea3acd4a92
|
|
BLAKE2b-256 checksum How to use checksums |
41a08af2031474e5ba221c482f27d486d8e5a2398002b6711a2e52114e8807ff
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
uv/0.11.23 {"installer":{"name":"uv","version":"0.11.23","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
|
Security for heatmapts 0.2.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.