New feature: hatching of polygons

Currently implemented for PostScript backend only - the rest

    > ignore the command. I tried to make it in the same style as
    > the rest of Matplotlib iface: 'x' does bidiagonal hatching
    > '/' does diagonal, '-' does horizontal, and so on.
    > Repeating the hatching symbol increases the density of
    > hatching.

    > Attached is the diff for version 0.85. Is there a chance
    > for this thing to be included into the source?

Thanks Alex -- I'm happy to include this but am having trouble
applying your patch. Could you get a fresh CVS checkout, reapply your
changes, and do a 'cvs diff'?

Thanks,
JDH

···

Only in matplotlib-0.85.new: build diff -r

    > matplotlib-0.85/lib/matplotlib/backend_bases.py
    > matplotlib-0.85.new/lib/matplotlib/backend_bases.py 389a390
    >> self._hatch = None
    > 401a403
    >> self._hatch = gc._hatch
    > 549c551,558 < ---
    >> def set_hatch(self, hatch): """ Sets the hatch style for
    >> filling """ self._hatch = hatch def get_hatch(self): return
    >> self._hatch
    > Only in matplotlib-0.85.new/lib/matplotlib:
    > backend_bases.py~ diff -r
    > matplotlib-0.85/lib/matplotlib/backends/backend_ps.py
    > matplotlib-0.85.new/lib/matplotlib/backends/backend_ps.py
    > 148a149,150
    >> self.hatch = None self.hatch_func = False
    > 195a198,260
    >> def set_hatch(self, hatch): """ hatch can be one of: / -
    >> diagonal hatching \ - back diagonal | - vertical - - horizontal
    >> # - crossed X - crossed diagonal letters can be combined, in
    >> which case all the specified hatchings are done if same letter
    >> repeats, it increases the density of hatching in that direction
    >> """ hatches = {'horiz':0, 'vert':0, 'diag1':0, 'diag2':0}
    >>
    >> for letter in hatch: if (letter == '/'): hatches['diag2'] += 1
    >> elif (letter == '\\'): hatches['diag1'] += 1 elif (letter ==
    >> '|'): hatches['vert'] += 1 elif (letter == '-'):
    >> hatches['horiz'] += 1 elif (letter == '+'): hatches['horiz'] +=
    >> 1 hatches['vert'] += 1 elif (letter == 'x'): hatches['diag1']
    >> += 1 hatches['diag2'] += 1
    >>
    >> def do_hatch(angle, density): if (density == 0): return "" orig
    >> = """ gsave eoclip %s rotate 0.0 0.0 0.0 0.0 setrgbcolor 0
    >> setlinewidth /gap %d def pathbbox /b exch def /r exch def /t
    >> exch def /l exch def l cvi gap idiv gap mul gap r cvi gap idiv
    >> gap mul {t moveto 0 b t sub rlineto} for stroke grestore """ %
    >> (angle, 12/density) return """ gsave eoclip %s rotate 0.0 0.0
    >> 0.0 0.0 setrgbcolor 0 setlinewidth /hatchgap %d def pathbbox
    >> /hatchb exch def /hatchr exch def /hatcht exch def /hatchl exch
    >> def hatchl cvi hatchgap idiv hatchgap mul hatchgap hatchr cvi
    >> hatchgap idiv hatchgap mul {hatcht moveto 0 hatchb hatcht sub
    >> rlineto} for stroke grestore """ % (angle, 12/density)
    >> self._pswriter.write("gsave\n")
    >> self._pswriter.write(do_hatch(0, hatches['horiz']))
    >> self._pswriter.write(do_hatch(90, hatches['vert']))
    >> self._pswriter.write(do_hatch(45, hatches['diag1']))
    >> self._pswriter.write(do_hatch(-45, hatches['diag2']))
    >> self._pswriter.write("grestore\n")
    >>
    > 771,772c836,837 < write(ps.strip()) < write("\n") ---
    >> write(ps.strip()) write("\n")
    > 778a844,847
    >> hatch = gc.get_hatch() if (hatch): self.set_hatch(hatch)
    >>
    > Only in matplotlib-0.85.new/lib/matplotlib/backends:
    > backend_ps.py~ diff -r
    > matplotlib-0.85/lib/matplotlib/patches.py
    > matplotlib-0.85.new/lib/matplotlib/patches.py 30a31
    >> hatch = None,
    > 44a46
    >> self.hatch = hatch
    > 53a56
    >> self.set_hatch(other.get_hatch())
    > 114a118,128
    >> def set_hatch(self, h): """ Set the hatching pattern
    >>
    >> ACCEPTS: string (can be one of "|,/,\,x,+", or combinations
    >> thereof") """ self.hatch = h
    >>
    >> def get_hatch(self): 'return the current hatch pattern' return
    >> self.hatch
    > 127a142,143
    >> if self.hatch != None: gc.set_hatch(self.hatch)
    > Only in matplotlib-0.85.new/lib/matplotlib: patches.py~ Only
    > in matplotlib-0.85.new: setupext.pyc Only in
    > matplotlib-0.85/src: _na_backend_agg.cpp Only in
    > matplotlib-0.85/src: _na_backend_gdk.c Only in
    > matplotlib-0.85/src: _na_cntr.c Only in matplotlib-0.85/src:
    > _na_image.cpp Only in matplotlib-0.85/src:
    > _na_transforms.cpp Only in matplotlib-0.85/src:
    > _nc_backend_agg.cpp Only in matplotlib-0.85/src:
    > _nc_backend_gdk.c Only in matplotlib-0.85/src: _nc_cntr.c
    > Only in matplotlib-0.85/src: _nc_image.cpp Only in
    > matplotlib-0.85/src: _nc_transforms.cpp