Code Search for Developers
 
 
  

boilerplate.py from matplotlib at Krugle


Show boilerplate.py syntax highlighted

# wrap the plot commands defined in axes.  The code generated by this
# file is pasted into pylab.py.  We did try to do this the smart way,
# with callable functions and new.function, but could never get the
# docstrings right for python2.2.  See
# http://groups-beta.google.com/group/comp.lang.python/messages/1b14640f3a4ad3dc,b3d7453af21e5f82,17739e70ac6f710c,9d5291fce29cbbb1,c5b578e4ffc6af28,056ff270daa2f414?thread_id=dcd63ec13096a0f6&mode=thread



# note we check for __doc__ is not None since py2exe optimize removes
# the docstrings

_fmtplot = """\
# This function was autogenerated by boilerplate.py.  Do not edit as
# changes will be lost
def %(func)s(*args, **kwargs):
    # allow callers to override the hold state by passing hold=True|False
    b = ishold()
    h = kwargs.pop('hold', None)
    if h is not None:
        hold(h)
    try:
        ret =  gca().%(func)s(*args, **kwargs)
        draw_if_interactive()
    except:
        hold(b)
        raise
    %(mappable)s
    hold(b)
    return ret
if Axes.%(func)s.__doc__ is not None:
    %(func)s.__doc__ = dedent(Axes.%(func)s.__doc__) + \"\"\"
Addition kwargs: hold = [True|False] overrides default hold state\"\"\"
"""

_fmtmisc = """\
# This function was autogenerated by boilerplate.py.  Do not edit as
# changes will be lost
def %(func)s(*args, **kwargs):

    ret =  gca().%(func)s(*args, **kwargs)
    draw_if_interactive()
    return ret
if Axes.%(func)s.__doc__ is not None:
    %(func)s.__doc__ = dedent(Axes.%(func)s.__doc__)
"""

# these methods are all simple wrappers of Axes methods by the same
# name.
_plotcommands = (
    'acorr',
    'arrow',
    'axhline',
    'axhspan',
    'axvline',
    'axvspan',
    'bar',
    'barh',
    'broken_barh',
    'boxplot',
    'cohere',
    'clabel',
    'contour',
    'contourf',
    'csd',
    'errorbar',
    'fill',
    'hist',
    'hlines',
    'imshow',
    'loglog',
    'pcolor',
    'pcolormesh',
    'pie',
    'plot',
    'plot_date',
    'psd',
    'scatter',
    'semilogx',
    'semilogy',
    'specgram',
    'spy',
    'stem',
    'step',
    'vlines',
    'quiver',
    'quiverkey',
    'xcorr',
    )

_misccommands = (
    'cla',
    'grid',
    'legend',
    'table',
    'text',
    'annotate',
    )

cmappable = {
    'contour' : 'if ret._A is not None: gci._current = ret',
    'contourf': 'if ret._A is not None: gci._current = ret',
    'scatter' : 'gci._current = ret',
    'pcolor'  : 'gci._current = ret',
    'pcolormesh'  : 'gci._current = ret',
    'imshow'  : 'gci._current = ret',
    'spy'    : 'gci._current = ret',
    'quiver2' : 'gci._current = ret',
    'quiver' : 'gci._current = ret',
    'specgram'  : 'gci._current = ret[-1]',

}


for func in _plotcommands:
    if cmappable.has_key(func):
        mappable = cmappable[func]
    else:
        mappable = ''
    print _fmtplot%locals()


for func in _misccommands:
    print _fmtmisc%locals()



# define the colormap functions
_fmtcmap = """\
# This function was autogenerated by boilerplate.py.  Do not edit as
# changes will be lost
def %(name)s():
    'set the default colormap to %(name)s and apply to current image if any.  See help(colormaps) for more information'
    rc('image', cmap='%(name)s')
    im = gci()


    if im is not None:
        im.set_cmap(cm.%(name)s)
    draw_if_interactive()

"""

cmaps = (
    'autumn',
    'bone',
    'cool',
    'copper',
    'flag',
    'gray' ,
    'hot',
    'hsv',
    'jet' ,
    'pink',
    'prism',
    'spring',
    'summer',
    'winter',
    'spectral'
)
# add all the colormaps (autumn, hsv, ....)
for name in cmaps:
    print _fmtcmap%locals()




See more files for this project here

matplotlib

Matplotlib is a pure python plotting library with the goal of making\r\npublication quality plots using a syntax familiar to matlab users. \r\nThe library uses Numeric for handling large\r\ndata sets and supports a variety of output backends

Project homepage: http://sourceforge.net/projects/matplotlib
Programming language(s): C,C++,Python
License: other

  CXX/
    Config.hxx
    Exception.hxx
    Extensions.hxx
    IndirectPythonInterface.cxx
    IndirectPythonInterface.hxx
    Objects.hxx
    Version.hxx
    WrapPython.h
    cxx_extensions.cxx
    cxxextensions.c
    cxxsupport.cxx
  agg23/
    font_freetype/
      Makefile.am
      agg_font_freetype.cpp
      agg_font_freetype.h
    font_win32_tt/
      agg_font_win32_tt.cpp
      agg_font_win32_tt.h
    include/
      ctrl/
      platform/
      util/
      Makefile.am
      agg_alpha_mask_u8.h
      agg_arc.h
      agg_array.h
      agg_arrowhead.h
      agg_basics.h
      agg_bezier_arc.h
      agg_bitset_iterator.h
      agg_bounding_rect.h
      agg_bspline.h
      agg_clip_liang_barsky.h
      agg_color_gray.h
      agg_color_rgba.h
      agg_config.h
      agg_conv_adaptor_vcgen.h
      agg_conv_adaptor_vpgen.h
      agg_conv_bspline.h
      agg_conv_clip_polygon.h
      agg_conv_clip_polyline.h
      agg_conv_close_polygon.h
      agg_conv_concat.h
      agg_conv_contour.h
      agg_conv_curve.h
      agg_conv_dash.h
      agg_conv_gpc.h
      agg_conv_marker.h
      agg_conv_marker_adaptor.h
      agg_conv_segmentator.h
      agg_conv_shorten_path.h
      agg_conv_smooth_poly1.h
      agg_conv_stroke.h
      agg_conv_transform.h
      agg_conv_unclose_polygon.h
      agg_curves.h
      agg_dda_line.h
      agg_ellipse.h
      agg_ellipse_bresenham.h
      agg_embedded_raster_fonts.h
      agg_font_cache_manager.h
      agg_gamma_functions.h
      agg_gamma_lut.h
      agg_glyph_raster_bin.h
      agg_gsv_text.h
      agg_image_filters.h
      agg_line_aa_basics.h
      agg_math.h
      agg_math_stroke.h
      agg_path_storage.h
      agg_path_storage_integer.h
      agg_pattern_filters_rgba.h
      agg_pixfmt_amask_adaptor.h
      agg_pixfmt_gray.h
      agg_pixfmt_rgb.h
      agg_pixfmt_rgb_packed.h
      agg_pixfmt_rgba.h
      agg_rasterizer_outline.h
      agg_rasterizer_outline_aa.h
      agg_rasterizer_scanline_aa.h
      agg_render_scanlines.h
      agg_renderer_base.h
      agg_renderer_markers.h
    src/
    svg/
  examples/
  lib/
  license/
  mpl1/
  sandbox/
  src/
  swig/
  ttconv/
  unit/
  API_CHANGES
  CHANGELOG
  CODING_GUIDE
  DEVNOTES
  INSTALL
  INTERACTIVE
  KNOWN_BUGS
  MANIFEST
  MANIFEST.in
  Makefile
  README
  SEGFAULTS
  TODO
  __init__.py
  boilerplate.py
  license.py
  makeswig.py
  matplotlibrc.template
  setup.cfg
  setup.py
  setupegg.py
  setupext.py