Create a scatter plot with a smoothed trend line and split it into side-by-side panels by category in a few lines of Python
Build charts for reports or presentations and save them as image files using professional or xkcd hand-drawn themes
Port existing R ggplot2 visualizations to Python with a nearly identical API and syntax
plotnine is a Python library for making charts and graphs. It is based on a popular R charting library called ggplot2, and brings the same approach to Python. The core idea is called a grammar of graphics: instead of calling a function that produces a specific chart type, you describe a chart by stating which columns in your data correspond to which visual properties, like position on the x-axis, position on the y-axis, color, or size. The library then assembles the chart from those descriptions. This approach means you build a chart piece by piece by adding layers. You might start with a scatter plot, then add a smoothed trend line on top of it, then split the result into separate side-by-side panels for each category in your data, then adjust the visual theme. Each of those additions is a separate line of code that gets combined with a plus sign. The README walks through exactly this sequence using a car dataset as an example, with images showing the result at each step. Theme options include a professional minimalist look and an intentionally hand-drawn look styled after the web comic xkcd. Plots can be saved as image files for use in reports or presentations. Installation is via pip or conda, the standard Python package managers. The base install is enough for most uses, with optional extras for testing, documentation generation, and development. A development version can also be installed directly from the repository. For users already familiar with R's ggplot2, the API is intentionally similar, and the ggplot2 documentation can serve as a reference when plotnine's own docs are incomplete. The project is open to contributions, particularly example plots that demonstrate useful techniques with real data.
← has2k1 on gitmyhub — every repo by this author, as a profile.
Verify against the repo before relying on details.