Menu

Tree [r5674] / trunk / matplotlib / examples / api /
 History

HTTPS access


File Date Author Commit
 README.txt 2008-05-16 jdh2358 [r5161] updated api readme
 agg_oo.py 2008-05-16 jdh2358 [r5153] renamed pylot to api for examples
 barchart_demo.py 2008-05-16 jdh2358 [r5151] reorganized examples
 collections_demo.py 2008-06-05 mdboom [r5403] Fix dpi-changing-related bugs in Axes.scatter()
 color_cycle.py 2008-05-24 efiring [r5251] Forgot to add the example on last commit
 colorbar_only.py 2008-05-16 jdh2358 [r5151] reorganized examples
 custom_projection_example.py 2008-06-20 mdboom [r5617] Removing redundant cla() method. (Thanks Tony ...
 custom_scale_example.py 2008-05-23 mdboom [r5230] Move examples from pylab to api.
 date_demo.py 2008-05-16 jdh2358 [r5151] reorganized examples
 date_index_formatter.py 2008-06-09 jdh2358 [r5436] added date index formatter example
 histogram_demo.py 2008-06-05 jdh2358 [r5407] added api histogram demo which comments on the ...
 image_zcoord.py 2008-05-18 jdh2358 [r5188] added z coordinate example for nearest neighbor...
 logo2.py 2008-06-25 jdh2358 [r5674] renamed axesPatch, axesFrame and figurePatch to...
 mathtext_asarray.py 2008-06-20 jdh2358 [r5618] added origin support for composite images
 patch_collection.py 2008-06-17 mdboom [r5583] Add a generic PatchCollection class.
 path_patch_demo.py 2008-05-30 jdh2358 [r5322] updated path example
 scatter_piecharts.py 2008-05-16 jdh2358 [r5151] reorganized examples
 watermark_image.py 2008-06-24 jdh2358 [r5669] added simple watermark examples
 watermark_text.py 2008-06-24 jdh2358 [r5670] use plain text rather than text image for water...

Read Me

matplotlib API
==============

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
figures, axes and plottng commands.  There are a few documentation
resources for the API

  - the matplotlib artist tutorial :
    http://matplotlib.sourceforge.net/pycon/artist_api_tut.pdf

  - the "leftwich tutorial" :
    http://matplotlib.sourceforge.net/leftwich_tut.txt

 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 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
===================

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 = plt.figure()
    ax = fig.add_subplot(111) # or add_axes
    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()