[R] hatch or line fill

Ross Ihaka ihaka at stat.auckland.ac.nz
Thu Nov 23 21:32:18 CET 2000

On Thu, Nov 23, 2000 at 06:47:11PM +0100, Bruno Tassin wrote:
> M. Camanm posted in Jul 1999 the following message:
> "
> Is there any way to fill the bars in a barplot() with solid lines for
> postscript output, i.e. cross hatch or parallel
> lines, or a halftone gray rather than (semi) continuous-tone gray
> produced by gray()? S allows this, or at least
> used to, via the angle and density arguments to barplot(). The objective
> of course, is to produce camera ready
> black and white plots on a laser printer. The gray values produced by
> gray() do not reproduce well. "
> and Paul Murrel gave the following answer
> "
> implementing density and angle arguments are on the todo list. the bad
> news
> is that they're behind a number of more important bugs. the good news is
> that they get closer to the front of the todo list as more people
> request it "
> Is this point still on the ToDo list  ?

    Yes.  But no closer to the top :-(

    It's actually something which anyone who knows a bit of C
    programming and graphics could tackle.    It comes down to
    computing the intersection of infinite straight lines with
    each of the edges of the polygon,  sorting these intersections
    (left to right or top to bottom), and joining adjacent pairs of
    intersections with straight lines.

    A useful approach is to rotate the polygon so that the cross
    hatching lines are horizontal, then the intersection tests with
    the edges are easy.

    Two important points to consider are:

    (i) The lines should placed relative to a fixed point on the
    device, rather than to a vertex of the polygon being filled.
    This means that the cross hatching patterns of adjacent polygons
    will match.

    (ii) There is virtually no extra work in structuring the code
    so that it can handle polygons containing holes (this is a
    very useful capability).

    A couple of useful references are:

    Robert Cromley (1992). "Digital Cartography". Prentice-Hall.

    Paul Bourke's geometry pages:

r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !)  To: r-help-request at stat.math.ethz.ch

More information about the R-help mailing list