Sophie

Sophie

distrib > Fedora > 18 > i386 > by-pkgid > bf21b4394f4d7fa09e3626145d3315e0 > files > 486

python-matplotlib-doc-1.2.0-14.fc18.i686.rpm

.. _pylab_examples-step_demo:

pylab_examples example code: step_demo.py
=========================================



.. plot:: /builddir/build/BUILD/matplotlib-1.2.0/doc/mpl_examples/pylab_examples/step_demo.py

::

    import numpy as np
    from numpy import ma
    from matplotlib.pyplot import step, legend, xlim, ylim, show
    
    x = np.arange(1, 7, 0.4)
    y0 = np.sin(x)
    y = y0.copy() + 2.5
    
    step(x, y, label='pre (default)')
    
    y -= 0.5
    step(x, y, where='mid', label='mid')
    
    y -= 0.5
    step(x, y, where='post', label='post')
    
    y = ma.masked_where((y0>-0.15)&(y0<0.15), y - 0.5)
    step(x,y, label='masked (pre)')
    
    legend()
    
    xlim(0, 7)
    ylim(-0.5, 4)
    
    show()
    
    

Keywords: python, matplotlib, pylab, example, codex (see :ref:`how-to-search-examples`)