matplotlib / grid-strategy Goto Github PK
View Code? Open in Web Editor NEWLibrary to facilitate the arrangement of matplotlib subplots based on the number of plots
License: Apache License 2.0
Library to facilitate the arrangement of matplotlib subplots based on the number of plots
License: Apache License 2.0
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.
Currently the tests are emitting some warnings, that should be causing the tests to fail.
I think the setuptools
, attrs
or variants
configurations work well for this.
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.
RectangularStrategy, if get_grid takes in prime N, creates a one-row by N cols plots grid. This poses an issue with larger prime numbers (N > 3)
In our setup.cfg
, we should have python_requires = >=3.6
I believe you can use the quickstart utility from sphinx.
We may also want to add a tox env for building the docs.
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.
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?
Use setup.cfg
for everything if possible.
Best to base our tox configuration on the exemplary repos listed in the wiki.
I believe we should set isolated_build=True
.
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.
We should format all the code with black, this means:
black
's configuration to the pyproject.toml
tox
environment that runs black
on the codeblack
.Can we add an insert function to let users insert their premade figures into specific grids?
This project came up on the discourse. I'm just curious if it still works well with the constrained_layout rewrite?
We do not currently have any xfail
-ing tests, but we should still configure pytest
to treat all XPASS
es as failures.
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()
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?).
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
.
We should have tests/test_strategies.py
, using pytest
with parametrized tests.
I think we want to generate it from some Apache 2.0 boilerplate website.
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.
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.
See the badges on our repos to steal from, we should add:
A lot of this can probably be cribbed from MEP 30
Should be a list of all the authors who have contributed, see the comparable list for dateutil; it is unnecessary to include the dateutil
stuff about dual licensing and whatnot, but otherwise the format can be similar.
Currently I'm just globbing *.tar.gz
and *.whl
, maybe an assertion that exactly 2 things were found would be prudent.
We should make GridStrategy
public.
We should also add a docstring and an __all__ = ['GridStrategy']
attribute as well.
We can crib most of this from dateutil
.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.