Skip to content
James Ramsden edited this page Mar 26, 2025 · 2 revisions

Python Toolkit implements several plots. These are implementations of matplotlib plots, and are provided here with the intention that child toolkits of Python Toolkit will provide specialised implementations of these plots.

In the following documentation for these plots, the following datasets are used for the examples.

import pandas as pd
import random
import math

# create an example time-indexed series
date_range = pd.date_range(start='2017-01-01T00:00', end='2017-12-31T23:59', freq='h')
data = [-math.cos(2 * math.pi * d.hour / 24) + random.random() for d in date_range]
TIME_INDEXED_SERIES = pd.Series(data, index=date_range)

Diurnal

Plot a profile aggregated across days in the specified timeframe.

Args:
    series (pd.Series):
        A time-indexed Pandas Series object.
    ax (plt.Axes, optional):
        A matplotlib Axes object. Defaults to None.
    period (str, optional):
        The period to aggregate over. Must be one of "daily", "weekly", or "monthly". Defaults to "daily".
    **kwargs (Dict[str, Any], optional):
        Additional keyword arguments to pass to the matplotlib plotting function.
        legend (bool, optional):
            If True, show the legend. Defaults to True.

Returns:
    plt.Axes:
        A matplotlib Axes object.

Example usage

Create a diurnal plot with default parameters:

from python_toolkit.plot.diurnal import diurnal
diurnal(TIME_INDEXED_SERIES)

download

Clone this wiki locally