Skip to main content

Data clock charts using matplotlib.

Project description

Data Clock Visualisation Library

PyPI - Version PyPI - Downloads Python Version from PEP 621 TOML GitHub Actions Workflow Status GitHub deployments

Introduction

This library allows the user to create data clock graphs, using the matplotlib Python library.

Data clocks visually summarise temporal data in two dimensions, revealing seasonal or cyclical patterns and trends over time. A data clock is a circular chart that divides a larger unit of time into rings and subdivides it by a smaller unit of time into wedges, creating a set of temporal bins.

These temporal bins are symbolised using graduated colors that correspond to a count or aggregated value taking place in each time period.

The table below details the currently supported chart modes and the corresponding rings and wedges:

Mode Rings Wedges Description
YEAR_MONTH Years Months Years / January - December.
YEAR_WEEK Years Weeks Years / weeks 1 - 52.
WEEK_DAY Weeks Days of the week Weeks 1 - 52 / Monday - Sunday.
DOW_HOUR Days of the week Hour of day Monday - Sunday / 24 hours.
DAY_HOUR Days Hour of day Days 1 - 356 / 24 hours.

The full documentation can be viewed on the project GitHub Page.

Example charts

Chart examples have been generated using UK Department for Transport data 2010 - 2015.

import pandas as pd
from dataclocklib.charts import dataclock

data = pd.read_parquet(
    "https://raw.githubusercontent.com/andyrids/dataclocklib/main/tests/data/traffic_data.parquet.gzip"
)

chart_data, fig, ax = dataclock(
    data=data,
    date_column="Date_Time",
    mode="DOW_HOUR",
    spine_color="darkslategrey",
    grid_color="black",
    default_text=False
)

Data clock chart

import pandas as pd
from dataclocklib.charts import dataclock

data = pd.read_parquet(
    "https://raw.githubusercontent.com/andyrids/dataclocklib/main/tests/data/traffic_data.parquet.gzip"
)

chart_data, fig, ax = dataclock(
    data=data,
    date_column="Date_Time",
    mode="DOW_HOUR",
    spine_color="darkslategrey",
    grid_color="black",
    default_text=True
)

Data clock chart

import pandas as pd
from dataclocklib.charts import dataclock

data = pd.read_parquet(
    "https://raw.githubusercontent.com/andyrids/dataclocklib/main/tests/data/traffic_data.parquet.gzip"
)

chart_data, fig, ax = dataclock(
    data=data,
    date_column="Date_Time",
    mode="DOW_HOUR",
    default_text=True,
    spine_color="darkslategrey",
    grid_color="black",
    chart_title="**CUSTOM TITLE**",
    chart_subtitle="**CUSTOM SUBTITLE**",
    chart_period="**CUSTOM PERIOD**",
    chart_source="Source: UK Department for Transport",
    dpi=150
)

Data clock chart

import pandas as pd
from dataclocklib.charts import dataclock

data = pd.read_parquet(
    "https://raw.githubusercontent.com/andyrids/dataclocklib/main/tests/data/traffic_data.parquet.gzip"
)

chart_data, fig, ax = dataclock(
    data=data.query("Date_Time.dt.year.eq(2010)"),
    date_column="Date_Time",
    agg_column="Number_of_Casualties",
    agg="sum",
    mode="DOW_HOUR",
    cmap_name="X26",
    cmap_reverse=True,
    spine_color="honeydew",
    grid_color="honeydew",
    default_text=True,
    chart_title="UK Traffic Accident Casualties",
    chart_subtitle=None,
    chart_period="Period: 2010",
    chart_source="Source: https://data.dft.gov.uk/road-accidents-safety-data/dft-road-casualty-statistics-collision-last-5-years.csv",
    dpi=300
)

Data clock chart

Installation

You can install using pip:

python -m pip install dataclocklib

To install from GitHub use:

python -m pip install git+https://github.com/andyrids/dataclocklib.git

Development Installation

Astral uv is used as the Python package manager. To install uv see the installation guide @ uv documentation.

Clone the repository:

git clone git@github.com:andyrids/dataclocklib.git
cd dataclocklib

Sync the dependencies, including the dev dependency group and optional dependencies with uv:

uv sync --all-extras

Activate the virtual environment:

. .venv/bin/activate

Sphinx documentation

cd docs
make html

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

dataclocklib-0.2.0.tar.gz (28.1 MB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

dataclocklib-0.2.0-py3-none-any.whl (28.7 kB view details)

Uploaded Python 3

File details

Details for the file dataclocklib-0.2.0.tar.gz.

File metadata

  • Download URL: dataclocklib-0.2.0.tar.gz
  • Upload date:
  • Size: 28.1 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.5.11

File hashes

Hashes for dataclocklib-0.2.0.tar.gz
Algorithm Hash digest
SHA256 c5ac259a29f9a691a123a28295f00a4ed8e0c50d5a625bf18d879aee0c02c27a
MD5 0ba91d3ccda17a52c5507dcfa05f15c0
BLAKE2b-256 97e7d3c481a8fd53d24adaba1befe537df59710bf8590392c05a4f1b6a9bf9cd

See more details on using hashes here.

File details

Details for the file dataclocklib-0.2.0-py3-none-any.whl.

File metadata

File hashes

Hashes for dataclocklib-0.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 9010e9e4d8a7d5c5f49f1111b6f969331410123322fc644bfffec8a65a806285
MD5 7c48561a40e79e99e6bd2c66bd139bee
BLAKE2b-256 03db204869b626c487b7a446f67b545bdb7667a15a7f9440454c118aac9505f4

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page