use plt.subplots() in examples as much as possible #1458
Closed
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
At the recent LBL Software Carpentry Workshop, it was pointed out that there's
an inconsistency within our documentation for how to create new figures with
subplots.
Indeed, most examples were using the old way, something like:
This patch changes a whole bunch of instances like the above to:
We should strive to have a minimal amount of constants in our code,
especially unusual ones like
111
, which only make sense to Matlabrefugees. This PR ends up removing ~150 lines with subplot(X), where X is some constant, as well as a comparable number of plt.figure() calls.
I have left unchanged examples which were using axes keywords passed to
subplot() and add_subplot(), since those end up transforming things like:
to
which isn't necessarily better.
I also did not touch most of the user_interfaces examples, since those did not
involve using plt, but instead explicitly imported Figure, and used the OO
approach on Figure instances.
Also updated instaces where the old "import pylab as p" convention was used to
use our standard "import matplotlib.pyplot as plt"
I have also updated some, but not all uses of subplot(121) etc, but I'm a bit
exhausted after doing all of these.