A package for laying out figures with geometric constraints
Project description
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.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file matplotlib_layout-0.1.0.tar.gz.
File metadata
- Download URL: matplotlib_layout-0.1.0.tar.gz
- Upload date:
- Size: 41.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.12.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
6a2ad344c885fe073ac96ce13e619966811e70a1a8eb9fc406f03c9b7509bd70
|
|
| MD5 |
e6b9d32440f6b2cce785ca127d70be61
|
|
| BLAKE2b-256 |
f9f831c73b0e39ed440ffff74f46512922ad1613c086901efd2c3faff7a8aea8
|
File details
Details for the file matplotlib_layout-0.1.0-py3-none-any.whl.
File metadata
- Download URL: matplotlib_layout-0.1.0-py3-none-any.whl
- Upload date:
- Size: 37.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.12.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
81240c8f8500e5f64e84fceb2721d8f2fed1942eba8ec099475113af4824885e
|
|
| MD5 |
16e9a7b65d0c68dee5ec98d3bcb841ce
|
|
| BLAKE2b-256 |
d9372e508e884b96f9bf1ce7ee770c9512fc9f93fc473efe7faeb9a5ea458f23
|