Skip to main content

Extension package for plotnine with extra geoms, stats, composition, and animation

Project description

plotnine-extra

Extension package for plotnine that adds extra geoms, stats, plot composition, and animation support.

Installation

pip install plotnine-extra

This will automatically install plotnine as a dependency.

Usage

from plotnine_extra import *

This imports all of plotnine's public API plus the extra components provided by this package. You can also import from plotnine and plotnine_extra separately:

from plotnine import ggplot, aes, geom_point
from plotnine_extra import geom_pointdensity, annotation_stripes

Extra Components

Geoms

  • geom_pointdensity — Scatterplot with density estimation at each point
  • geom_spoke — Line segments parameterised by location, direction, and distance
  • annotation_stripes — Alternating background stripes, useful with geom_jitter

Stats

  • stat_pointdensity — Compute density estimation for each point

Plot Composition

Compose multiple plots using operators:

  • | — Arrange plots side by side (Beside)
  • / — Arrange plots vertically (Stack)
  • + — Arrange plots in a 2D grid (Wrap)
  • - — Arrange plots side by side at the same nesting level
  • & — Add to all plots in a composition
  • * — Add to top-level plots only
from plotnine import ggplot, aes, geom_point
from plotnine.data import mtcars
from plotnine_extra import plot_layout, plot_annotation

p1 = ggplot(mtcars, aes("wt", "mpg")) + geom_point()
p2 = ggplot(mtcars, aes("hp", "mpg")) + geom_point()

# Side by side
p1 | p2

# Stacked
p1 / p2

# With layout control
(p1 | p2) + plot_layout(widths=[1, 2])

# With annotation
(p1 | p2) + plot_annotation(title="My Composition")

Additional composition classes and functions:

  • Compose — Base class for compositions
  • Beside, Stack, Wrap — Composition subclasses
  • plot_layout — Customise composition layout (nrow, ncol, widths, heights)
  • plot_annotation — Add title, subtitle, caption, footer to compositions
  • plot_spacer — Add blank space in compositions

Animation

from plotnine import ggplot, aes, geom_point, lims
from plotnine_extra import PlotnineAnimation

plots = [
    ggplot(data_frame_i, aes("x", "y")) + geom_point() + lims(x=(0, 10), y=(0, 10))
    for data_frame_i in frames
]

ani = PlotnineAnimation(plots, interval=200)
ani.save("animation.gif")

Compatibility

  • Requires Python ≥ 3.10
  • Requires plotnine ≥ 0.15.3

Note: The composition and animation modules use plotnine's internal APIs and may break with future plotnine updates. Pin your plotnine version if stability is critical.

Development

git clone https://github.com/mdmanurung/plotnine-extra.git
cd plotnine-extra
pip install -e ".[all]"

Publishing to PyPI

This project uses trusted publishing (OIDC) via GitHub Actions — no API tokens needed.

One-time setup

  1. Create accounts on PyPI and TestPyPI

  2. Add trusted publishers on both PyPI and TestPyPI:

    • Go to your account → Publishing → Add a new pending publisher
    • Fill in:
      • PyPI project name: plotnine-extra
      • Owner: mdmanurung
      • Repository: plotnine-extra
      • Workflow name: publish.yml
      • Environment name: pypi (for PyPI) or testpypi (for TestPyPI)
  3. Create GitHub environments in your repository settings:

    • Go to Settings → Environments
    • Create two environments: pypi and testpypi

How to publish

  • To TestPyPI: Go to Actions → "Publish to PyPI / TestPyPI" → Run workflow → select testpypi
  • To PyPI: Create a GitHub Release (tag it as v0.1.0, etc.) — publishing happens automatically

Version bumping

Before publishing a new version, update the version in both:

  • pyproject.tomlversion = "X.Y.Z"
  • plotnine_extra/__init__.py__version__ = "X.Y.Z"

License

MIT License (same as plotnine)

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

plotnine_extra-0.1.0.tar.gz (42.0 kB view details)

Uploaded Source

Built Distribution

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

plotnine_extra-0.1.0-py3-none-any.whl (50.0 kB view details)

Uploaded Python 3

File details

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

File metadata

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

File hashes

Hashes for plotnine_extra-0.1.0.tar.gz
Algorithm Hash digest
SHA256 b6620b3e70e24fb1e6f69fc1e3cfa82cb7fa4009bddb930afdc1d5f301f7613e
MD5 93f770aecea3e1c4ab354c94fb0dbd8e
BLAKE2b-256 13d2c3140738d85c78c020ff5e5449825af8638265c75a42ba1ee6a333b0e902

See more details on using hashes here.

Provenance

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

Publisher: publish.yml on mdmanurung/plotnine-extra

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

File details

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

File metadata

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

File hashes

Hashes for plotnine_extra-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 85c5617b036d99a0ec5fd5d6d523bd49b82eae64ae9ce082a0a0c774bc847742
MD5 78b0611edbba3a28935b935a45bb3ae2
BLAKE2b-256 cdaaf90c8e819e8d677988392a766ff23d26ddd4e48c96575d8361723edf4c97

See more details on using hashes here.

Provenance

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

Publisher: publish.yml on mdmanurung/plotnine-extra

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