Progress
Initial changes added in 1.3. Conversion of the gallery is on-going.
29 September 2015 - The last pylab_examples
where pylab
is imported has been converted over to use matplotlib pyplot
and numpy
.
#1623, #1924, #2181
PR #2474 <https://github.com/matplotlib/matplotlib/pull/2474
>_
demonstrates a single example being cleaned up and moved to the
appropriate section.
Reorganizing the matplotlib plot gallery would greatly simplify navigation of the gallery. In addition, examples should be cleaned-up and simplified for clarity.
The matplotlib gallery was recently set up to split examples up into
sections. As discussed in that PR [1], the current example sections
(api
, pylab_examples
) aren’t terribly useful to users: New
sections in the gallery would help users find relevant examples.
These sections would also guide a cleanup of the examples: Initially, all the current examples would remain and be listed under their current directories. Over time, these examples could be cleaned up and moved into one of the new sections.
This process allows users to easily identify examples that need to be
cleaned up; i.e. anything in the api
and pylab_examples
directories.
The naming of sections is critical and will guide the clean-up effort. The current sections are:
These names are certainly up for debate. As these sections grow, we should reevaluate them and split them up as necessary.
The current examples in the api
and pylab_examples
sections of
the gallery would remain in those directories until they are cleaned
up. After clean-up, they would be moved to one of the new gallery
sections described above. “Clean-up” should involve:
PEP8 clean-ups (running flake8, or a similar checker, is highly recommended)
Commented-out code should be removed.
Add introductory sentence or paragraph in the main docstring. See 6d1b8a2.
Replace uses of pylab
interface with pyplot
(+ numpy
,
etc.). See c25ef1e
Remove shebang line, e.g.:
#!/usr/bin/env python
Use consistent imports. In particular:
import numpy as np
import matplotlib.pyplot as plt
Avoid importing specific functions from these modules (e.g. from
numpy import sin
)
Each example should focus on a specific feature (excluding
showcase
examples, which will show more “polished”
plots). Tweaking unrelated to that feature should be removed. See
f7b2217,
e57b5fc,
and 1458aa8
Use of pylab
should be demonstrated/discussed on a dedicated help
page instead of the gallery examples.
Note: When moving an existing example, you should search for
references to that example. For example, the API documentation for
axes.py
and pyplot.py
may use these examples to generate
plots. Use your favorite search tool (e.g., grep, ack, grin, pss) to search the matplotlib
package. See 2dc9a46
and aa6b410
plt.subplots
(note trailing “s”) in preference over
plt.subplot
.imshow
might be imshow_demo.py
, and one
demonstrating different interpolation settings would be
imshow_demo_interpolation.py
(not imshow_demo2.py
).unit
directory located in the root directory of the package.The website for each Matplotlib version is readily accessible, so users who want to refer to old examples can still do so.
Tagging examples will also help users search the example gallery. Although tags would be a big win for users with specific goals, the plot gallery will remain the entry point to these examples, and sections could really help users navigate the gallery. Thus, tags are complementary to this reorganization.
[1] | https://github.com/matplotlib/matplotlib/pull/714 |
[2] | https://github.com/matplotlib/matplotlib/issues/524 |
[3] | http://matplotlib.1069221.n5.nabble.com/Matplotlib-gallery-td762.html#a33379091 |
[4] | http://www.labri.fr/perso/nrougier/teaching/matplotlib/ |
[5] | http://www.labri.fr/perso/nrougier/coding/gallery/ |