MPLLayout
Summary
MPLLayout is a package to create precise figure layouts in matplotlib. It works by modelling figure elements using geometric primitives (for example, text anchors are points, the figure is a quadrilateral, etc.), then constraining the sizes and positions of these elements using geometric constraints (for example, fixing the width of a figure, constraining axes sides to be collinear, constraining axes to lie on a grid, etc.).
Using this approach, MPLLayout can:
- align figure elements (axes, text label location, x and y axis, etc.),
- specify margins around axes,
- create templates for figures across different mediums (posters, manuscripts, slides, etc.),
- and more!
Basic usage
The tutorial notebook in examples/tutorial.ipynb demonstrates the basic usage of the package and explains some of the commonly used geometric constraints.
Other examples are also given in the examples folder.
The notebook at examples/ten_simple_rules_demo.ipynb contains an interactive demo to recreate a figure from "Ten Simple Rules For Better Figures" (Rougier, Droettboom and Bourne 2014).
A summary of how to use the package is shown in the figure below.
The process resembles creating and constraining geometry in computer-aided design programs like AutoCAD, SolidWorks, etc.
Motivation
Matplotlib contains several strategies for creating figure layouts (for example, GridSpec and subplots for grid-based layouts).
While these approaches work well, greater control over figure element positions is sometimes desirable;
for example, when preparing figures for published documents, research papers, or slides.
Installation
You can install the package from PyPI using
pip install matplotlib-layout
Alternateively, clone the repository into a local drive. Navigate to the project directory and run
pip install .
The package requires numpy, matplotlib, and jax.
Contributing
This project is a work in progress so there are likely bugs and missing features. If you would like to contribute a bug fix, a feature, refactor etc. thank you! All contributions are welcome.
Motivation and Similar Projects
A similar project with a geometric constraint solver is pygeosolve.
There is also another project prototype for a constraint-based layout engine for matplotlib MplLayouter, although it doesn't seem active as of 2023.
Metadata
Release files for matplotlib-layout 0.1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| matplotlib_layout-0.1.0.tar.gz | 41.9 kB | Without provenance | Details for matplotlib_layout-0.1.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| matplotlib_layout-0.1.0-py3-none-any.whl | Python 3 | none | any | Details for matplotlib_layout-0.1.0-py3-none-any.whl |
Total release size: 79.8 kB
Release files / matplotlib_layout-0.1.0.tar.gz
| Download URL | matplotlib_layout-0.1.0.tar.gz |
|---|---|
| Size | 41.9 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
6a2ad344c885fe073ac96ce13e619966811e70a1a8eb9fc406f03c9b7509bd70
|
|
BLAKE2b-256 checksum How to use checksums |
f9f831c73b0e39ed440ffff74f46512922ad1613c086901efd2c3faff7a8aea8
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.2 CPython/3.12.7
|
Release files / matplotlib_layout-0.1.0-py3-none-any.whl
| Download URL | matplotlib_layout-0.1.0-py3-none-any.whl |
|---|---|
| Size | 37.9 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
81240c8f8500e5f64e84fceb2721d8f2fed1942eba8ec099475113af4824885e
|
|
BLAKE2b-256 checksum How to use checksums |
d9372e508e884b96f9bf1ce7ee770c9512fc9f93fc473efe7faeb9a5ea458f23
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.2 CPython/3.12.7
|
Security for matplotlib-layout 0.1.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.