Skip to main content

epiplot

CI PyPI

Plots for epidemiology and public health research, with good practice built in.

📖 Documentation: https://leehart3000.github.io/epiplot/

An epidemic curve made with epiplot

Status

Early development (alpha). Ready to try:

  • Epidemic curves: cases over time.
  • Rate maps: rates by region, for one period or as a timeline.
  • Survival curves: Kaplan–Meier curves, with a number-at-risk table.

Install

pip install epiplot

For rate maps, which need GeoPandas, install the extra map libraries too:

pip install "epiplot[maps]"

Requires Python 3.13 or newer. Works in Google Colab, which already includes GeoPandas.

Epidemic curves

import pandas as pd

import epiplot

# One row per case (a "line list").
cases = pd.DataFrame(
    {
        "onset_date": ["2026-03-02", "2026-03-04", "2026-03-10", "2026-03-11", None],
        "origin": ["Local", "Travel", "Local", "Local", "Travel"],
    }
)

ax = epiplot.epicurve(cases, "onset_date", date_type="onset", group_col="origin")
ax.figure.savefig("epicurve.png")

For the counts behind the plot, as a table, use epiplot.count_cases().

Good practice built in:

  • Says what the dates mean. Onset, report, specimen or diagnosis dates tell different stories, so epiplot labels the axis to match, and warns if the date type isn't given.
  • Shows empty periods as zero, so gaps in an outbreak stay visible.
  • Reports cases with missing dates under the plot, instead of silently leaving them out.
  • Shades recent periods that may be incomplete because of reporting delays, if you give it a date.
  • Uses colour-blind-safe colours, with missing groups in grey.
  • Supports ISO weeks (starting Monday) and US CDC weeks (starting Sunday).

Rate maps

A timeline of rate maps made with epiplot, using made-up districts

# regions: a GeoPandas table of region shapes, with an "area_code" column.
# data: one row per region, with "cases" and "population" columns.
ax = epiplot.rate_map(
    regions, data, "area_code", cases_col="cases", population_col="population"
)

# One small map per period, all sharing one colour scale.
figure = epiplot.rate_map_timeline(
    regions,
    data_by_month,
    "area_code",
    "month",
    cases_col="cases",
    population_col="population",
)

For the rates behind the maps, with exact 95% confidence intervals, use epiplot.calculate_rates(). Rates you have already calculated, such as age-standardised rates, can be mapped with rate_col and rate_label.

Good practice built in:

  • Maps rates, not raw counts, since counts mostly show where people live. Rates are clearly labelled as crude rates.
  • Hides regions with fewer than 5 cases, whose rates are unreliable and could identify individuals.
  • Shows "no data" differently from zero, so gaps in reporting aren't mistaken for no disease.
  • Uses a single-colour scale starting at zero, with colour bands as an option.
  • Timelines share one colour scale, so the same shade means the same rate in every period.

Survival curves

Kaplan-Meier survival curves comparing time to relapse for 6-MP and placebo, made with epiplot

Start with one row per person, with a follow-up time and whether the event happened (1) or the person was censored (0):

ax = epiplot.survival_curve(
    trial, "weeks", "relapsed", time_unit="weeks", group_col="treatment"
)

Good practice built in:

  • Time unit on the axis. If time_unit is not given, epiplot warns and says so on the axis.
  • Number at risk. A table under the plot shows how many people are still being followed, because the right-hand end of a curve often rests on very few people.
  • Uncertainty and censoring shown. Shaded 95% confidence bands, and tick marks where people were censored.
  • Honest scale. The y axis always runs from 0% to 100%.

For the estimates behind the plot, as a table, use epiplot.kaplan_meier(). The example uses real data from a 1963 leukaemia trial (Freireich et al.).

More examples

Fuller examples are in the examples folder.

License

BSD 3-Clause. See LICENSE.

Metadata

Release files for epiplot 0.4.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for epiplot 0.4.1
File Size Uploaded Provenance Actions
epiplot-0.4.1.tar.gz 32.2 kB With provenance Details for epiplot-0.4.1.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for epiplot 0.4.1
File Interpreter ABI Platform Actions
epiplot-0.4.1-py3-none-any.whl Python 3 none any Details for epiplot-0.4.1-py3-none-any.whl

Total release size: 56.4 kB

Release files / epiplot-0.4.1.tar.gz

Download URL epiplot-0.4.1.tar.gz
Size 32.2 kB
Tags Source
SHA-256 checksum
How to use checksums
9461b33febc7e919d8522917b42dcef797eb608f5cb6d65c6920eb6c98a1aaa9
BLAKE2b-256 checksum
How to use checksums
d4880469695d57248165f1d067babd3b2febf4ee2fa05f11d74f50532abd688b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

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.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 2, 2026.

Transparency log

Release files / epiplot-0.4.1-py3-none-any.whl

Download URL epiplot-0.4.1-py3-none-any.whl
Size 24.1 kB
Tags Python 3
SHA-256 checksum
How to use checksums
6339831ad55472f1303c93d52c5b86eb6d7b468e649847630459e502b0d19ff2
BLAKE2b-256 checksum
How to use checksums
6e3318f93ac91d3b246646c2f5c54d9f5b80e11013908fe571bbd5f63d015863
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

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.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 2, 2026.

Transparency log

Security for epiplot 0.4.1

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.

Full provenance

Both files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for epiplot-0.4.1.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 2, 2026.

Transparency log

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.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page