Skip to main content

prettypyplot

The documentation including an gallery can be found here.

This is a wrapper package for matplotlib to achieve more easily pretty figures. If you are looking for something complete, this project is nothing for you but maybe seaborn. The main aspect of this project is to help me syncing my rcParams files and to stop copy-pasting so much code.

The aim of this project is to simplify the generation of some simple pre-defined figures. Almost all code is inspired or taken from the matplotlib gallery. If you are a power user or interested in generating complex figures, this packages is not ment for you and you should better take a look in the matplotlib gallery directly.

This project is in an alpha stage, hence it is neither stable nor ready for production.

CAUTION: Starting from version 1.0.0 (which is far in the future) API-breaking changes will be made only in major releases. Until then, it can be changed in every minor release (see changelog).

Features

The most notable features are:

  • Tested with matplotlib 3.5-3.11, for 3.3 and 3.4 please use pplt <=0.12.0
  • figsize specifies size of canvas. So labels, ticks or colorbars are not counted.
  • Nice top-aligned outter legends
  • New colors

Usage

This package uses an syntax very close to matplotlib. Hence, it should be straight forward to use it. Instead of calling a function on the axes itself, one needs to pass here the axes as an argument (args or kwargs).

Installation

python3 -m pip install --upgrade prettypyplot

or

conda install -c conda-forge prettypyplot

or for the latest dev version

python3 -m pip install git+https://github.com/braniii/prettypyplot.git

Usage

import matplotlib.pyplot as plt
import prettypyplot as pplt

pplt.use_style()
fig, ax = plt.subplots()
...
pplt.plot(ax=ax, x, y)
pplt.savefig(output)

Known Bugs

  • plt.subplots_adjust() does not work with pplt.savefig(use_canvas_size=True) If you find one, please open an issue.
  • pplt.savefig(use_canvas_size=True) is not compatible with a grid of subplots

Known Workarounds

The method pyplot.subplots_adjust() is not compatible with the option use_canvas_size in prettypyplot.plot.savefig, use instead:

# this doesn't work, use instead gridspec
fig.subplots_adjust(hspace=0)
# use this instead
fig, axs = plt.subplots(..., gridspec_kw={'hspace': 0.000})

Comparison to matplotlib

matplotlib.pyplot.plot
prettypyplot.plot
matplotlib.pyplot.legend
prettypyplot.legend
matplotlib.pyplot.imshow
prettypyplot.imshow
matplotlib.pyplot.colorbar
prettypyplot.colorbar

Roadmap:

The following list is sorted from near future to hopefully ever.

  • add pytest
  • add search functionality in doc
  • refactoring code to improve readabilty
  • add package to conda_forge
  • add gallery page
  • improve plt.suplots() behaviour together with pplt.savefig()
  • add more colorpalettes
  • add countour line plot
  • add axes_grid examples
  • setup widths and scaling factors for beamer and poster mode
  • tweak all function to enable STYLE='minimal'
  • implement tufte style

Building Documentation:

The doc is based on mkdocs and can be created by

# installing all dependencies
python -m pip install -e .[docs]

# serve interactively
python -m mkdocs serve

Similar Projects

Citing Prettypyplot

If you want to cite prettypyplot in scientific work please use:

Prettypyplot: publication ready matplotlib figures made simple
D. Nagel, 2022. Zenodo: 10.5281/zenodo.7278312

Credits:

In alphabetical order:

Metadata

Release files for prettypyplot 0.13.3

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for prettypyplot 0.13.3
File Size Uploaded
prettypyplot-0.13.3.tar.gz 996.7 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for prettypyplot 0.13.3
File Interpreter ABI Platform
prettypyplot-0.13.3-py3-none-any.whl Python 3 none any Details

Total release size: 1.0 MB

Release files / prettypyplot-0.13.3.tar.gz

Download URL prettypyplot-0.13.3.tar.gz
Size 996.7 kB
Tags Source
SHA-256 checksum
How to use checksums
9a1251356bc7d389ed81c4dbf27a97ec311f56f1628734077eb45c69dd266890
BLAKE2b-256 checksum
How to use checksums
0165d3a77869bb7713fe59193e27f3b9301e0cb79fb587ca94fa3cc54f53b4d1
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via uv/0.11.31 {"installer":{"name":"uv","version":"0.11.31","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

Release files / prettypyplot-0.13.3-py3-none-any.whl

Download URL prettypyplot-0.13.3-py3-none-any.whl
Size 43.1 kB
Tags Python 3
SHA-256 checksum
How to use checksums
4f9c316f3da81fa870a7eefc5a752ec6e38a11a866cbc830a17062529d23bf6b
BLAKE2b-256 checksum
How to use checksums
b1c9cb1662df894dadf49602a63ee40e87a2fe8a2bd2aa63e63d8a2a7d067cc0
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via uv/0.11.31 {"installer":{"name":"uv","version":"0.11.31","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

Release history Release notifications | RSS feed

This release

0.13.3 This release

2 release files

0.12.0

2 release files

0.11.0

2 release files

0.10.1

2 release files

0.9.0

2 release files

0.8.0

2 release files

0.7.1

2 release files

0.7.0

2 release files

0.6.0

2 release files

0.5.0

2 release files

0.4.2

2 release files

0.4.0

2 release files

0.3.0

2 release files

0.2.3

2 release files

0.2.2

2 release files

0.2.1

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page