Skip to main content

grid-strategy

PyPI version Build Status Documentation Status codecov

Grid-strategy is a python package that enables the user organize matplotlib plots using different grid strategies.

Abstract

This package would add a mechanism for creating a grid of subplots based on the number of axes to be plotted and a strategy for how they should be arranged, with some sensible strategy as the default.

Detailed Description

It is often the case that you have some number of plots to display (and this number may be unknown ahead of time), and want some sensible arrangement of the plots so that they are all roughly equally aligned. However, the subplots and gridspec methods for creating subplots require both an x and a y dimension for creation and population of a grid. This package would allow users to specify a strategy for the creation of a grid, and then specify how many axes they want to plot, and they would get back a collection of axes arranged according to their strategy.

A proof of concept was implemented for the 'squarish' strategy, which arranges plots in alternating rows of x and x-1 objects. Some examples featuring this technique:

n=6 n=7

n=8 n=17

This makes use of a GridStrategy object, which populates a GridSpec. In general, this concept can likely be implemented as a layer of abstraction above gridspec.GridSpec.

Some basic strategies that will be included in the first release:

  • "Squarish" (name subject to change) - As implemented in the demo code above - currently this is centered, but the base SquarishStrategy object could have options like justification which could include:
    • 'center' (default), 'left', 'right' - empty spaces either center the plots or leave them ragged-left or ragged-right
    • 'fill-space' and fill-grow' (names subject to change) - These would fill every column as "fully-justified", with fill-space increasing the interstitial space and fill-grow modifying the width of the plots themselves to fill the row.
  • "Rectangular" - Similar to "Squarish", this would find the largest pair of factors of the number of plots and use that to populate a rectangular grid - so 6 would return a 3x2 grid, 7 would return a 7x1 grid, and 10 would return a 5x2 grid.

Since many of these grid strategies would likely have at least some asymmetries, a mechanism for transposing any grid structure should be implemented in the base GridStrategy object.

Higher dimensions

Currently the package is limited to 2-dimensional grid arrangements, but a "nice-to-have" might be a higher-order API for GridStrategy that also allows for the proliferation of additional figures (e.g. "if I have more than 10 axes to plot, split them up as evenly as possible among n / 10 different figures"). This would be no harder to implement in terms of the creation of such strategies, but may be harder to work with since it would necessarily spawn axes across multiple figures.

Metadata

Release files for grid-strategy 0.0.1

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

Source distribution (sdist)

Source distribution for grid-strategy 0.0.1
File Size Uploaded
grid-strategy-0.0.1.tar.gz 17.2 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for grid-strategy 0.0.1
File Interpreter ABI Platform
grid_strategy-0.0.1-py3-none-any.whl Python 3 none any Details

Total release size: 28.4 kB

Release files / grid-strategy-0.0.1.tar.gz

Download URL grid-strategy-0.0.1.tar.gz
Size 17.2 kB
Tags Source
SHA-256 checksum
How to use checksums
d8db1c12e6f33eb55ba56a5b19f4848aae862a9a343fea422a353c46ab6ccc23
BLAKE2b-256 checksum
How to use checksums
36a82822c49ef0b1daeb8a536be0602cb1fdd03d72f3ede123cfed2dabccb247
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/1.13.0 pkginfo/1.5.0.1 requests/2.21.0 setuptools/40.8.0 requests-toolbelt/0.9.1 tqdm/4.31.1 CPython/3.7.2

Release files / grid_strategy-0.0.1-py3-none-any.whl

Download URL grid_strategy-0.0.1-py3-none-any.whl
Size 11.2 kB
Tags Python 3
SHA-256 checksum
How to use checksums
43c74e3394798dc136b8d0c2c98e2fa62467c8289751f4ef4b7c37a2475bd2f5
BLAKE2b-256 checksum
How to use checksums
42119087f3c536651b0076cfa008be9b6e343c3bbbf18ea4bd7e2fac27e4bcde
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/1.13.0 pkginfo/1.5.0.1 requests/2.21.0 setuptools/40.8.0 requests-toolbelt/0.9.1 tqdm/4.31.1 CPython/3.7.2

Release history Release notifications | RSS feed

This release

0.0.1 This release

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