Skip to main content

A matplotlib-style Python library for generating Mermaid diagrams

Reason this release was yanked:

no license

Project description

sea-nymph

Do you want to show plots in your documentation? Do you want to avoid committing PNGs to git? Do you have an (un)reasonable dislike for SVG files? Look no further!

sea-nymph generates Mermaid charts from Python — plain text that renders natively on GitHub, GitLab, and most modern documentation tools. No image files, no binary blobs, just code.

The API is modelled after seaborn: pass a DataFrame, name your columns, get a chart.

Installation

pip install sea-nymph

sea-nymph uses narwhals under the hood, so it accepts any DataFrame library — pandas, polars, PyArrow, and more.

High-level API

import polars as pl
from sea_nymph import barplot, lineplot, countplot, histplot, kdeplot

df = pl.DataFrame({
    "month": ["Jan", "Feb", "Mar", "Apr"],
    "revenue": [10, 40, 30, 50],
    "region": ["North", "North", "South", "South"],
})

fig = barplot(df, x="month", y="revenue")
print(fig.render())
xychart-beta
    x-axis [Jan, Feb, Mar, Apr]
    y-axis "Revenue" 0 --> 50
    bar [10, 40, 30, 50]

Available plot functions

Function Description
barplot Bar chart with optional aggregation
lineplot Line chart with optional aggregation
countplot Count (or proportion/percent) of categorical values
histplot Histogram with configurable bins and statistics
kdeplot Kernel density estimate using Silverman's rule

All functions support a hue parameter for grouped series, hue_order and order for controlling category ordering, and palette for custom colours.

Hue

fig = barplot(df, x="month", y="revenue", hue="region", palette=["#4e79a7", "#f28e2b"])

Stat

countplot and histplot accept a stat parameter:

countplot(df, x="month", stat="percent")   # "count" | "percent" | "proportion" | "probability"
histplot(df, x="revenue", stat="density")  # "count" | "frequency" | "probability" | "proportion" | "percent" | "density"

Horizontal charts

Pass y instead of x to flip the orientation:

countplot(df, y="region")
kdeplot(df, y="revenue")

Low-level API

For full control, use XYChart from sea_nymph.mermaidplotlib directly:

from sea_nymph.mermaidplotlib import XYChart

months = ["Jan", "Feb", "Mar", "Apr"]
fig = XYChart()
fig.bar(months, [10, 40, 30, 50])
fig.line(months, [15, 35, 25, 45])
fig.xlabel("Month")
fig.ylabel("Revenue (k)")
fig.ylim(0, 60)
fig.title("Sales 2024")
print(fig.render())
xychart-beta
    title "Sales 2024"
    x-axis "Month" [Jan, Feb, Mar, Apr]
    y-axis "Revenue (k)" 0 --> 60
    bar [10, 40, 30, 50]
    line [15, 35, 25, 45]

Limitations

Mermaid's xychart-beta places all data points equidistantly on the axis. This means:

  • Line charts require evenly-spaced numeric x values — sea-nymph raises an error if they are not.
  • Histograms require equal-width bins for the same reason — unequal bin widths are rejected.
  • Bar charts are not affected (categories are inherently discrete).

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

sea_nymph-0.1.0.tar.gz (7.1 kB view details)

Uploaded Source

Built Distribution

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

sea_nymph-0.1.0-py3-none-any.whl (11.2 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: sea_nymph-0.1.0.tar.gz
  • Upload date:
  • Size: 7.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for sea_nymph-0.1.0.tar.gz
Algorithm Hash digest
SHA256 6c6b9a1244575aa8ea940a097ed7218916320797bdbf43524f4df0ff73ad0f45
MD5 74c07bca09c63fed3c91070adcbae538
BLAKE2b-256 2da2f87f0954a869920d59d3474f280f201ab3b4f0222a9b4b278fc9eaeb6c7a

See more details on using hashes here.

Provenance

The following attestation bundles were made for sea_nymph-0.1.0.tar.gz:

Publisher: publish.yml on Excidion/sea-nymph

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

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

File metadata

  • Download URL: sea_nymph-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 11.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for sea_nymph-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 c5ed4f597e743328b6d110a7021fdf1a1ed0fe5af8bd052de06bc3e363194452
MD5 afe999ff2a364cb6eed9062f711d648f
BLAKE2b-256 5481ce1c0d13c3027d2e29d4b9f4c4856be0e787b9fa6e087e84b795e92014b7

See more details on using hashes here.

Provenance

The following attestation bundles were made for sea_nymph-0.1.0-py3-none-any.whl:

Publisher: publish.yml on Excidion/sea-nymph

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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