Code Monkey home page Code Monkey logo

grid-strategy's Introduction

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 adds 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.

The SquareStrategy alternates rows of x and x-1 columns to get as close as possible to a square shape for the plots. 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:

  • "Square" - As implemented in the pictures above - currently this is centered, but the base SquareStrategy object has options for alignment which include:

    • 'center' (default), 'left', 'right' - empty spaces either center the plots or leave them ragged-left or ragged-right
    • 'justified' - This will fill every column as "fully-justified", with some plots being stretched to fill all of the colums in the row.
  • "Rectangular" - Similar to "Square", 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.

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.

Installation Instructions

Simply run: pip install grid-strategy

Then, in your project, do: from grid_strategy import strategies

The strategies module has all usable strategies.

grid-strategy's People

Contributors

pganssle avatar gurnek avatar konoikon avatar smeng10 avatar morganhaworth avatar

Watchers

James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.