Skip to content

DOC api's transition to sphinx-gallery is now complete #8311

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Mar 19, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions doc/faq/howto_faq.rst
Original file line number Diff line number Diff line change
Expand Up @@ -397,7 +397,7 @@ locators as desired because the two axes are independent.

.. htmlonly::

See :ref:`api-two_scales` for a complete example
See :ref:`api-plot_two_scales` for a complete example

.. _howto-batch:

Expand Down Expand Up @@ -643,7 +643,7 @@ For more on configuring your backend, see

Alternatively, you can avoid pylab/pyplot altogether, which will give
you a little more control, by calling the API directly as shown in
:ref:`api-agg_oo`.
:ref:`api-plot_agg_oo`.

You can either generate hardcopy on the filesystem by calling savefig::

Expand Down
2 changes: 1 addition & 1 deletion doc/users/legend_guide.rst
Original file line number Diff line number Diff line change
Expand Up @@ -290,7 +290,7 @@ Here is a non-exhaustive list of the examples available involving legend
being used in various ways:

* :ref:`lines_bars_and_markers-scatter_with_legend`
* :ref:`api-legend_demo`
* :ref:`api-plot_legend`
* :ref:`pylab_examples-contourf_hatching`
* :ref:`pylab_examples-figlegend_demo`
* :ref:`pylab_examples-scatter_symbol`
7 changes: 4 additions & 3 deletions doc/users/prev_whats_new/whats_new_1.1.rst
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,11 @@ Sankey Diagrams

Kevin Davies has extended Yannick Copin's original Sankey example into a module
(:mod:`~matplotlib.sankey`) and provided new examples
(:ref:`api-sankey_demo_basics`, :ref:`api-sankey_demo_links`,
:ref:`api-sankey_demo_rankine`).
(:ref:`api-plot_sankey_basics`, :ref:`api-plot_sankey_links`,
:ref:`api-plot_sankey_rankine`).

.. plot:: mpl_examples/api/plot_sankey_rankine.py

.. plot:: mpl_examples/api/sankey_demo_rankine.py

Animation
---------
Expand Down
2 changes: 1 addition & 1 deletion doc/users/prev_whats_new/whats_new_1.4.rst
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ matplotlib internals were cleaned up to support using such transforms in
:class:`~matplotlib.Axes`. This transform is important for some plot types,
specifically the Skew-T used in meteorology.

.. plot:: mpl_examples/api/skewt.py
.. plot:: mpl_examples/api/plot_skewt.py

Support for specifying properties of wedge and text in pie charts.
``````````````````````````````````````````````````````````````````
Expand Down
2 changes: 1 addition & 1 deletion doc/users/prev_whats_new/whats_new_1.5.rst
Original file line number Diff line number Diff line change
Expand Up @@ -367,7 +367,7 @@ kwargs names is not ideal, but `Axes.fill_between` already has a

This is particularly useful for plotting pre-binned histograms.

.. plot:: mpl_examples/api/filled_step.py
.. plot:: mpl_examples/api/plot_filled_step.py


Square Plot
Expand Down
4 changes: 2 additions & 2 deletions doc/users/screenshots.rst
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@ Date demo
You can plot date data with major and minor ticks and custom tick formatters
for both.

.. plot:: mpl_examples/api/date_demo.py
.. plot:: mpl_examples/api/plot_date.py

See :mod:`matplotlib.ticker` and :mod:`matplotlib.dates` for details and usage.

Expand Down Expand Up @@ -217,7 +217,7 @@ The :func:`~matplotlib.pyplot.legend` command automatically
generates figure legends, with MATLAB-compatible legend placement
commands.

.. plot:: mpl_examples/api/legend_demo.py
.. plot:: mpl_examples/api/plot_legend.py

Thanks to Charles Twardy for input on the legend command.

Expand Down
2 changes: 1 addition & 1 deletion doc/users/transforms_tutorial.rst
Original file line number Diff line number Diff line change
Expand Up @@ -452,4 +452,4 @@ best way to learn more is to open the source for those packages and
see how to make your own, since matplotlib supports extensible axes
and projections. Michael Droettboom has provided a nice tutorial
example of creating a hammer projection axes; see
:ref:`api-custom_projection_example`.
:ref:`api-plot_custom_projection_example`.
33 changes: 6 additions & 27 deletions examples/api/README.txt
Original file line number Diff line number Diff line change
@@ -1,39 +1,18 @@
matplotlib API
.. _api_examples:

Matplotlib API
==============

These examples use the matplotlib api rather than the pylab/pyplot
These examples use the Matplotlib api rather than the pylab/pyplot
procedural state machine. For robust, production level scripts, or
for applications or web application servers, we recommend you use the
matplotlib API directly as it gives you the maximum control over your
Matplotlib API directly as it gives you the maximum control over your
figures, axes and plottng commands.

The example agg_oo.py is the simplest example of using the Agg backend
which is readily ported to other output formats. This example is a
good starting point if your are a web application developer. Many of
the other examples in this directory use matplotlib.pyplot just to
the other examples in this directory use ``matplotlib.pyplot`` just to
create the figure and show calls, and use the API for everything else.
This is a good solution for production quality scripts. For full
fledged GUI applications, see the user_interfaces examples.

Example style guide
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there any reason to get rid of this section? It seems quite useful.

Copy link
Member Author

@NelleV NelleV Mar 18, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is not the correct place to document example style guide. We have a MEP for this in addition of contributors guidelines on how to write documentation (this section is thus quite out of date).

In addition, the READMEs are now being rendered in the gallery: they thus should contain documentation relevant to the end user on this specific section of the gallery instead of a mixture of user documentation and contribution guidelines.

Does this make sense?

===================

If you are creating new examples, you cannot import pylab or import *
from any module in your examples. The only three functions allowed
from pyplot are "figure", "show" and "close", which you can use as
convenience functions for managing figures. All other matplotlib
functionality must illustrate the API.

A simple example of the recommended style is::

import numpy as np
import matplotlib.pyplot as plt

fig, ax = plt.subplots()
ax.plot(np.random.rand(10))
ax.set_xlabel('some x data')
ax.set_ylabel('some y data')
ax.set_title('some title')
ax.grid(True)
fig.savefig('myfig')
plt.show()
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion lib/matplotlib/axes/_axes.py
Original file line number Diff line number Diff line change
Expand Up @@ -508,7 +508,7 @@ def legend(self, *args, **kwargs):
Examples
--------

.. plot:: mpl_examples/api/legend_demo.py
.. plot:: mpl_examples/api/plot_legend.py

"""
handlers = kwargs.get('handler_map', {}) or {}
Expand Down
2 changes: 1 addition & 1 deletion lib/matplotlib/path.py
Original file line number Diff line number Diff line change
Expand Up @@ -318,7 +318,7 @@ def make_compound_path_from_polys(cls, XY):
numsides x 2) numpy array of vertices. Return object is a
:class:`Path`

.. plot:: mpl_examples/api/histogram_path_demo.py
.. plot:: mpl_examples/api/plot_histogram_path.py

"""

Expand Down
2 changes: 1 addition & 1 deletion lib/matplotlib/sankey.py
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ def __init__(self, ax=None, scale=1.0, unit='', format='%G', gap=0.25,

**Examples:**

.. plot:: mpl_examples/api/sankey_demo_basics.py
.. plot:: mpl_examples/api/plot_sankey_basics.py
"""
# Check the arguments.
if gap < 0:
Expand Down