skillfed

plotnine

A Grammar of Graphics for Python

plotnine v0.15.8 3.4M downloads/30d#2,629 on PyPI4,760
Permissive license The MIT License (MIT) Copyright (c) 2022 Hassan Kibirige Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the… (full text in the JSON record) Active released

What it is and what it does

plotnine is a Python implementation of the grammar of graphics, modeled on R's ggplot2. It lets you build plots declaratively by mapping variables from a pandas DataFrame to visual properties (axes, colors, sizes, shapes) and then layering geometric objects, statistics, and themes using the `+` operator. Each layer is added incrementally, making it easy to build complex visualizations step by step while keeping simple plots simple.

The package depends on matplotlib for rendering, pandas for data handling, and scipy and statsmodels for statistical transformations. It works across macOS, Windows, and Unix, and supports current Python versions (3.10–3.13). The API mirrors ggplot2 closely, so R users can transfer their plotting intuition directly, and the documentation points to ggplot2 references where plotnine's coverage is incomplete.

Use it for:

  • Build exploratory scatter plots with color-coded groups and trend lines, composing layers incrementally without rewriting the whole plot.
  • Create publication-ready multi-panel plots using faceting to compare distributions or relationships across categorical subsets of data.
  • Apply consistent themes and styling to a suite of plots by defining a theme once and reusing it across multiple visualizations.
  • Perform statistical visualization (smoothing, confidence intervals, density estimation) by combining geoms with stats like stat_smooth.
  • Prototype complex plots interactively in notebooks, adding and removing layers to refine the visualization without switching tools.

Worth the install?

AI-flagged interpretation of the facts on this page — verify before relying

plotnine implements a grammar of graphics for Python, letting you build plots by explicitly mapping dataframe variables to visual properties like position, color, and size, then composing them with operators.

Yes. plotnine is actively maintained, has no known vulnerabilities, installs with low friction, and offers a genuinely different (and for many users, more intuitive) approach to plotting than matplotlib's imperative style. It's well-suited for exploratory analysis and publication graphics if you prefer declarative composition. The MIT license is unrestricted. Install it if you work with pandas DataFrames and want to think about plots as layered grammars rather than imperative drawing commands.

Install

plotnine on PyPI

pip

pip install plotnine

uv

uv add plotnine

poetry

poetry add plotnine

Installing plotnine

Before you install

Low friction install with a pure-Python wheel. Active maintenance (last commit 2026-08-14) and a stable dependency set on matplotlib, pandas, numpy, scipy, statsmodels, and mizani. Supports Python 3.10 through 3.13.

License in practice

MIT license (permissive). You can use, modify, and distribute plotnine freely in commercial and private projects with minimal restrictions, provided you include the license notice.

Quickstart

pip install plotnine

from plotnine import ggplot, aes, geom_point
from plotnine.data import mtcars

(ggplot(mtcars, aes('wt', 'mpg'))
 + geom_point())

Verify before relying

  • Whether image-based testing (comparing generated plots to baselines) is required for contributions or only for development.
  • Performance characteristics with large datasets or complex multi-layer plots.
  • Extent of API coverage compared to ggplot2 and which features may still be missing.

Package facts

License The MIT License (MIT) Copyright (c) 2022 Hassan Kibirige Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the… (full text in the JSON record) (permissive)
Python support supports the current Python release (>=3.10)
Install friction low — pure-Python wheel
Runtime dependencies 6 — matplotlib, pandas, mizani, numpy, scipy, statsmodels
Maintenance actively maintained — 0 days since the last release
Last repo commit
First released
Downloads 3,416,684/month — #2,629 on PyPI (30-day window, as of 2026-08-14)
Known vulnerabilities none known (OSV.dev, checked 2026-08-14)

Evidence: plotnine-0.15.8-py3-none-any.whl

Framework :: MatplotlibIntended Audience :: Science/ResearchLicense :: OSI Approved :: MIT LicenseOperating System :: MacOSOperating System :: Microsoft :: WindowsOperating System :: UnixProgramming Language :: Python :: 3 :: OnlyProgramming Language :: Python :: 3.10Programming Language :: Python :: 3.11Programming Language :: Python :: 3.12Programming Language :: Python :: 3.13Topic :: Scientific/Engineering :: Visualization

Tags

grammar of graphics pythonggplot2 python equivalentdeclarative plotting dataframelayered plot compositionstatistical graphics pythondata visualization grammarmatplotlib alternative plotting
data-visualizationgrammar-of-graphicsggplot2-inspired

More Visualization packages