plotnine 0.15.8


pip install plotnine

  Latest version

Released: Aug 14, 2026


Meta
Author: Hassan Kibirige
Requires Python: >=3.10

Classifiers

Intended Audience
  • Science/Research

License
  • OSI Approved :: MIT License

Operating System
  • Microsoft :: Windows
  • Unix
  • MacOS

Programming Language
  • Python :: 3 :: Only
  • Python :: 3.10
  • Python :: 3.11
  • Python :: 3.12
  • Python :: 3.13

Framework
  • Matplotlib

Topic
  • Scientific/Engineering :: Visualization

plotnine

Release License DOI Build Status Coverage

plotnine is an implementation of a grammar of graphics in Python based on ggplot2. The grammar allows you to compose plots by explicitly mapping variables in a dataframe to the visual characteristics (position, color, size etc.) of objects that make up the plot.

Plotting with a grammar of graphics is powerful. Custom (and otherwise complex) plots are easy to think about and build incrementally, while the simple plots remain simple to create.

To learn more about how to use plotnine, check out the documentation. Since plotnine has an API similar to ggplot2, where it lacks in coverage the ggplot2 documentation may be helpful.

Example

from plotnine import *
from plotnine.data import mtcars

Building a complex plot piece by piece.

  1. Scatter plot

    (
        ggplot(mtcars, aes("wt", "mpg"))
        + geom_point()
    )
    
  2. Scatter plot colored according some variable

    (
        ggplot(mtcars, aes("wt", "mpg", color="factor(gear)"))
        + geom_point()
    )
    
  3. Scatter plot colored according some variable and smoothed with a linear model with confidence intervals.

    (
        ggplot(mtcars, aes("wt", "mpg", color="factor(gear)"))
        + geom_point()
        + stat_smooth(method="lm")
    )
    
  4. Scatter plot colored according some variable, smoothed with a linear model with confidence intervals and plotted on separate panels.

    (
        ggplot(mtcars, aes("wt", "mpg", color="factor(gear)"))
        + geom_point()
        + stat_smooth(method="lm")
        + facet_wrap("gear")
    )
    
  5. Adjust the themes

    I) Make it playful

    (
        ggplot(mtcars, aes("wt", "mpg", color="factor(gear)"))
        + geom_point()
        + stat_smooth(method="lm")
        + facet_wrap("gear")
        + theme_xkcd()
    )
    

    II) Or professional

    (
        ggplot(mtcars, aes("wt", "mpg", color="factor(gear)"))
        + geom_point()
        + stat_smooth(method="lm")
        + facet_wrap("gear")
        + theme_tufte()
    )
    

Installation

Official release

# Using pip
$ pip install plotnine             # 1. should be sufficient for most
$ pip install 'plotnine[extra]'    # 2. includes extra/optional packages
$ pip install 'plotnine[test]'     # 3. testing
$ pip install 'plotnine[doc]'      # 4. generating docs
$ pip install 'plotnine[dev]'      # 5. development (making releases)
$ pip install 'plotnine[all]'      # 6. everything

# Or using conda
$ conda install -c conda-forge plotnine

# Or using pixi
$ pixi init name-of-my-project
$ cd name-of-my-project
$ pixi add python plotnine

Development version

$ pip install git+https://github.com/has2k1/plotnine.git

Contributing

Our documentation could use some examples, but we are looking for something a little bit special. We have two criteria:

  1. Simple looking plots that otherwise require a trick or two.
  2. Plots that are part of a data analytic narrative. That is, they provide some form of clarity showing off the geom, stat, ... at their differential best.

If you come up with something that meets those criteria, we would love to see it. See plotnine-examples.

If you discover a bug checkout the issues if it has not been reported, yet please file an issue.

And if you can fix a bug, your contribution is welcome.

Testing

Plotnine has tests that generate images which are compared to baseline images known to be correct. To generate images that are consistent across all systems you have to install matplotlib from source. You can do that with pip using the command.

$ pip install matplotlib --no-binary matplotlib

Otherwise there may be small differences in the text rendering that throw off the image comparisons.

0.16.0a14 Sep 11, 2026
0.16.0a13 Sep 01, 2026
0.16.0a12 Aug 15, 2026
0.16.0a11 Jun 15, 2026
0.16.0a10 Jun 13, 2026
0.16.0a9 Jun 10, 2026
0.16.0a8 May 25, 2026
0.16.0a7 Mar 10, 2026
0.16.0a6 Mar 09, 2026
0.16.0a5 Mar 09, 2026
0.16.0a4 Mar 06, 2026
0.16.0a3 Feb 03, 2026
0.16.0a2 Jan 19, 2026
0.16.0a1 Jan 19, 2026
0.15.8 Aug 14, 2026
0.15.7 Jun 13, 2026
0.15.6 Jun 10, 2026
0.15.5 Jun 02, 2026
0.15.4 May 05, 2026
0.15.3 Jan 28, 2026
0.15.2 Dec 12, 2025
0.15.1 Oct 30, 2025
0.15.0 Jul 15, 2025
0.15.0a8 Jul 14, 2025
0.15.0a7 Jul 10, 2025
0.15.0a6 Jul 03, 2025
0.15.0a5 Jun 27, 2025
0.15.0a4 Jun 25, 2025
0.15.0a3 Jun 20, 2025
0.15.0a2 May 19, 2025
0.15.0a1 Apr 23, 2025
0.15.0.dev3 Apr 07, 2025
0.15.0.dev2 Mar 31, 2025
0.15.0.dev1 Mar 24, 2025
0.14.6 Jun 25, 2025
0.14.5 Jan 02, 2025
0.14.4 Dec 16, 2024
0.14.3 Nov 26, 2024
0.14.2 Nov 21, 2024
0.14.1 Nov 05, 2024
0.14.0 Oct 28, 2024
0.13.6 May 09, 2024
0.13.5 Apr 26, 2024
0.13.4 Apr 03, 2024
0.13.3 Mar 27, 2024
0.13.2 Mar 14, 2024
0.13.1 Mar 06, 2024
0.13.0 Feb 20, 2024
0.12.4 Nov 06, 2023
0.12.3 Sep 01, 2023
0.12.2 Jul 21, 2023
0.12.1 May 09, 2023
0.12.0 May 09, 2023
0.10.1 Sep 29, 2022
0.10.0 Sep 29, 2022
0.9.0 Jul 01, 2022
0.8.0 Mar 25, 2021
0.7.1 Aug 05, 2020
0.7.0 Jun 05, 2020
0.6.0 Aug 21, 2019
0.5.1 Oct 17, 2018
0.5.0 Oct 16, 2018
0.4.0 Aug 01, 2018
0.3.0 Nov 08, 2017
0.2.1 Jun 22, 2017
0.2.0 May 18, 2017
0.1.0 Apr 25, 2017

Wheel compatibility matrix

Platform Python 3
any

Files in release

Extras:
Dependencies:
matplotlib (>=3.8.0)
pandas (>=2.2.0)
mizani (~=0.14.0)
numpy (>=1.23.5)
scipy (>=1.8.0)
statsmodels and (<=0.14.4)
statsmodels or (>=0.14.6)