.. _pylab_examples-hatch_demo:

pylab_examples example code: hatch_demo.py
==========================================



.. plot:: /build/buildd/matplotlib-0.98.5.2/doc/mpl_examples/pylab_examples/hatch_demo.py

::

    """
    Hatching (pattern filled polygons) is supported currently on PS
    backend only.  See the set_patch method in
    http://matplotlib.sf.net/matplotlib.patches.html#Patch
    for details
    """
    import matplotlib
    matplotlib.use('PS')
    from pylab import figure
    
    fig = figure()
    ax = fig.add_subplot(111)
    bars = ax.bar(range(1,5), range(1,5), color='gray', ecolor='black')
    
    patterns = ('/', '+', 'x', '\\')
    for bar, pattern in zip(bars, patterns):
         bar.set_hatch(pattern)
    fig.savefig('hatch4.ps')
    

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