Skip to main content

Lightweight Cohort Flow Diagrams built on Matplotlib.

Project description

pycohortflow logo

pycohortflow

Lightweight cohort flow diagrams built on Matplotlib.

Turn a plain Python list of cohort steps into a publication-ready vertical flow chart with a single function call. Colours, fonts, spacing, and box geometry are fully customisable via TOML configuration files.

Installation

pip install pycohortflow

Quick Start

from pycohortflow import plot_cohort_flow_diagram
import matplotlib.pyplot as plt

data = [
    {"heading": "Registered Patients", "N": 350,
     "description": "Total patients registered in database"},
    {"heading": "Screening", "N": 150,
     "exclusion_description": "Did not meet inclusion criteria"},
    {"heading": "Eligible", "N": 120,
     "exclusion_description": "Declined / Lost to follow-up"},
    {"heading": "Final Analysis", "N": 115,
     "exclusion_description": "Data incomplete"},
]

fig, ax = plot_cohort_flow_diagram(
    data,
    figure_title="Clinical Cohort Flow Diagram",
)
plt.show()

Built-in Styles

Two styles ship with the package:

White style preview Colorful style preview

# Clean white boxes (default)
fig, ax = plot_cohort_flow_diagram(data, style="white")

# Pastel gradient backgrounds
fig, ax = plot_cohort_flow_diagram(data, style="colorful")

# Transparent figure background (for slides / posters)
fig, ax = plot_cohort_flow_diagram(data, transparent=True)

Customisation

Create a TOML file with only the values you want to override:

[figure]
dpi = 300

[colors]
main_start = "#cce5ff"
main_end   = "#d4edda"

Then pass it when plotting:

fig, ax = plot_cohort_flow_diagram(data, style_config_path="my_style.toml")

See the full documentation for all available options.

Saving Figures

fig, ax = plot_cohort_flow_diagram(
    data,
    save_dir="output",
    img_name="flow_chart",
    save_format=["png", "svg", "pdf"],
)

Requirements

  • Python >= 3.9
  • Matplotlib >= 3.5

License

AGPL-3.0 license


Roadmap

  • python based PRISMA2020 style generation, if necessary

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

pycohortflow-0.1.0.tar.gz (38.3 kB view details)

Uploaded Source

Built Distribution

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

pycohortflow-0.1.0-py3-none-any.whl (25.5 kB view details)

Uploaded Python 3

File details

Details for the file pycohortflow-0.1.0.tar.gz.

File metadata

  • Download URL: pycohortflow-0.1.0.tar.gz
  • Upload date:
  • Size: 38.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.9

File hashes

Hashes for pycohortflow-0.1.0.tar.gz
Algorithm Hash digest
SHA256 3e0b8e519fb46ced5df58e37690c49a8e083ba5a89ab8d483d4f08ef68e49ff7
MD5 33067fe33af2f7075068f9397bd8a9c2
BLAKE2b-256 c9295862eb0ae8fc28d67ce125f8f68f6d31492b940236958540c6df6f6d2390

See more details on using hashes here.

File details

Details for the file pycohortflow-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: pycohortflow-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 25.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.9

File hashes

Hashes for pycohortflow-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 bf244081d8009888f21d49342487212e857f64d1586367611dae551250694640
MD5 225b49eb74e112af12915c5a697f511a
BLAKE2b-256 2360c358dd424ef3e131075dceacff7318b0f25588db5be0f99d271ebad98d8b

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