GithubHelp home page GithubHelp logo

matplotlib / grid-strategy Goto Github PK

View Code? Open in Web Editor NEW
40.0 3.0 16.0 100 KB

Library to facilitate the arrangement of matplotlib subplots based on the number of plots

License: Apache License 2.0

Python 100.00%

grid-strategy's People

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

grid-strategy's Issues

Declare dependency on matplotlib

We need to add an explicit dependency on matplotlib for now (we can drop it later if it becomes optional because we've added another plotting backend).

It should be added under [options] in setup.cfg, it is under the install_requires section.

Add towncrier

I think the setuptools, attrs or variants configurations work well for this.

Allow users to specify an aspect ratio for SquareStrategy

Per my comments in #50, I think we should probably create a version of SquareStrategy that allows you to specify a target aspect ratio other than 1:1.

The nomenclature is all messed up and I'm wondering if we should rename this project and a bunch of the classes in it before too many people start using it, but for now we can just call it RectangleStrategy, and make SquareStrategy a subclass of it.

Add hypothesis tests

There's at least one property test that I think would be useful: we can assert that:

def test_arrangement(strategy, n):
    sum(strategy.get_grid_arrangement(n)) == n

Getting a grid arrangement that has the number of plots we want in it.

We just need to add hypothesis to the test dependencies and design an appropriate (hypothesis) strategy.

I don't understand how to use this

Hi,

I'm very new to matplotlib and I'm creating figures in a loop and I'd like to arrange them nicely.

Can someone add example code to the README that shows how to apply the strategies in this package?

Add support for other backends

Right now this only works with matplotlib, but it would be good to decouple grid-strategy from that a bit and make it possible to add additional backends.

Specifically, I'd like to support bqplot as well.

Add the black formatter

We should format all the code with black, this means:

  1. Add black's configuration to the pyproject.toml
  2. Add a tox environment that runs black on the code
  3. Add a CI job that ensures that all the code has been formatted with black.

Does this work w 3.4 (master)

This project came up on the discourse. I'm just curious if it still works well with the constrained_layout rewrite?

Set up strict xfail

We do not currently have any xfail-ing tests, but we should still configure pytest to treat all XPASSes as failures.

Use matplotlib sphinx extensions to build documentation

We should have a few simple examples in the documentation, generated inline with the matplotlib plotting extensions for sphinx.

For example, we can use this to generate one of the main figures:

.. plot::

   import matplotlib.pyplot as plt
   from grid_strategy.strategies import SquareStrategy

   specs = SquareStrategy('center').get_grid(7)

   for i, spec in enumerate(specs):
      ax = plt.subplot(spec)

      ax.text(0.5, 0.5, f"Subplot: {i}", color='white',
             fontweight='bold', va="center", ha="center")
      ax.tick_params(axis='both', bottom=False, top=False, left=False,
                    right=False, labelbottom=False, labelleft=False)

      ax.patch.set_facecolor('#2E2E2E')

   plt.show()

Consider not relying on constrained layout

Overall this looks fun.

Super happy you are using constrained layout, but suggest you make it optional somehow. There are some times when it'll fail and users will want a way to turn it off.

I'm also not sure about initializing the figure inside of your helper, instead of letting the user pass it (optionally?).

Configure code coverage

Once we have tox and CI set up, we would also like to start checking the code coverage automatically. See the repos to steal from, dateutil and setuptools both have code coverage configured through tox.

Add tests

We should have tests/test_strategies.py, using pytest with parametrized tests.

Add LICENSE file

I think we want to generate it from some Apache 2.0 boilerplate website.

Add additional justification options

Right now "fully justified" changes the shape of the plots, we could change that to two different justification modes. In the original MEP, I proposed two "fully justified" modes, fill-grow and fill-space, where fill-grow would have the plots grow to fill the space and fill-space would distribute the extra space between the plots.

Add CI

Probably Azure Pipelines and/or Travis CI. See the repos to steal from section - tox, virtualenv and dateutil all have strong Azure Pipelines pipelines, but note!

We only support Python >= 3.6, so we can get away with a much less elaborate set of pipelines and jobs. 3.6, 3.7 and 3.8-dev (allowed failure), on Linux, Mac and Windows I think should be sufficient.

Add badges!

See the badges on our repos to steal from, we should add:

  • Docs badge
  • Azure pipelines badge
  • PyPI badge (don't worry it won't work until we make a release)
  • Codecov (though that can be added as part of the "add code cov" PR)

Fill out __init__.py

We should make GridStrategy public.

We should also add a docstring and an __all__ = ['GridStrategy'] attribute as well.

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.