matplotlib

This Page

Quick search

pylab_examples example code: hatch_demo.pyΒΆ

[source code]

../../_images/hatch_demo.png
"""
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 Search examples)