Skip to main content

Data clock charts using matplotlib.

Project description

Data Clock Visualisation Library

Python version status

[!NOTE] This library is a work in progress and is frequently updated.

TODO

  • Publish to PyPI.
  • Add unit tests for chart generation & data aggregation.
  • Add tutorial section to GitHub Page documentation.

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"
)

graph_data, fig, ax = dataclock(
    data=data.query("Date_Time.dt.year.ge(2015)"),
    date_column="Date_Time",
    agg_column="Number_of_Casualties",
    agg="sum",
    mode="DOW_HOUR",
    cmap_name="CMRmap_r",
    chart_title="UK Car Accident Casualties 2015",
    chart_subtitle=None,
    chart_source="www.kaggle.com/datasets/silicon99/dft-accident-data"
)

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"
)

graph_data, fig, ax = dataclock(
    data=data.query("Date_Time.dt.year.eq(2010)"),
    date_column="Date_Time",
    agg_column=None,
    agg="count",
    mode="DOW_HOUR",
    cmap_name="RdYlGn_r",
    chart_title="UK Car Accidents 2010",
    chart_subtitle=None,
    chart_source="www.kaggle.com/datasets/silicon99/dft-accident-data"
)

Data clock chart

Installation

You can install using pip:

python -m pip install dataclocklib

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

Dependencies

dataclocklib
├── matplotlib v3.10.0
├── pandas[parquet] v2.2.3
├── sphinx v8.1.3 (extra: docs)
├── sphinx-autobuild v2024.10.3 (extra: docs)
└── sphinx-rtd-theme v3.0.2 (extra: docs)

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.1.4.tar.gz (19.8 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.1.4-py3-none-any.whl (21.7 kB view details)

Uploaded Python 3

File details

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

File metadata

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

File hashes

Hashes for dataclocklib-0.1.4.tar.gz
Algorithm Hash digest
SHA256 d0fa2f129def66da3f722c4d308c09e47688b530be57e8493adf647a08bf7e86
MD5 ffff5530ac08c06919a483b252c99147
BLAKE2b-256 babed5bef692aade248a8d489a6ce32cc95691c7a38943997839ee869a1628b8

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for dataclocklib-0.1.4-py3-none-any.whl
Algorithm Hash digest
SHA256 9e205c1e33e98c0cf915d8e42bc1a900e9e00e317a5690cb961d247b4f7e2224
MD5 fc14045610d90391c9fa9c99c7bb900c
BLAKE2b-256 63f51ca07bd651250638c6514aee8542b1283e3aa66f6a471f5339cddd06d508

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