Skip to main content

Wrapper for matplotlib to generate pretty plots.

Project description

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.10, 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:

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

prettypyplot-0.13.2.tar.gz (976.5 kB view details)

Uploaded Source

Built Distribution

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

prettypyplot-0.13.2-py3-none-any.whl (42.8 kB view details)

Uploaded Python 3

File details

Details for the file prettypyplot-0.13.2.tar.gz.

File metadata

  • Download URL: prettypyplot-0.13.2.tar.gz
  • Upload date:
  • Size: 976.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: uv/0.11.11 {"installer":{"name":"uv","version":"0.11.11","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}

File hashes

Hashes for prettypyplot-0.13.2.tar.gz
Algorithm Hash digest
SHA256 56fd39f51f0959fc1da2e1b34c4522199aec92dad82d38f9fd2cbaff2013766d
MD5 274ab8639ac0aad4ee776299aac66000
BLAKE2b-256 d7423704ff3c17aace67f0dcabd9fb07b37be42ec445abd041cba9a8a6027c14

See more details on using hashes here.

File details

Details for the file prettypyplot-0.13.2-py3-none-any.whl.

File metadata

  • Download URL: prettypyplot-0.13.2-py3-none-any.whl
  • Upload date:
  • Size: 42.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: uv/0.11.11 {"installer":{"name":"uv","version":"0.11.11","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}

File hashes

Hashes for prettypyplot-0.13.2-py3-none-any.whl
Algorithm Hash digest
SHA256 394068d0a3b7e7c64e5342557640636d0a9f063855373b1cc85020a1d5b2e038
MD5 eaa5eba843db42c04b4a01e602e020d9
BLAKE2b-256 6d2c6d04e08dae58dc4b0c2ee8f284a36c0d1968c1199ecd366024bf83537bbd

See more details on using hashes here.

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