[R] erasing an area of a graph

Jim Lemon jim at bitwrit.com.au
Fri Apr 9 13:22:16 CEST 2010


On 04/09/2010 04:51 AM, Terry Therneau wrote:
> I have a case where the easiest way to draw a particular symbol would be
> to draw something a little bigger, and then use polygon(... , col=0) to
> erase the extra stuff.  Just how to do this best when par('bg') =
> 'transparent' is, however, eluding me.  I've looked through the archives
> and the book R Graphics without quite seeing the light.
>    Help or pointers to help would be welcome.
>
> Terry T
>
> Details (for the inquiring mind).  In drawing a pedigree  subjects are
> depicted as cirle, square, diamond, or triangle (for gender= male,
> female, unknown, terminated).  This can be subdivided into shaded
> regions to show the value of various ancillary variables.  One ancillary
> is easy - just fill with a color.  For two you fill the left and right
> half separately, etc.  Two, three, four, ... variables become special
> cases for each symbol.  An easy solution is to draw a larger circle with
> the requisite number of shaded slices, then erase away what we don't
> want.
>
Hi Terry,
The kludge that is used in axis.break and similar functions is to set 
the polygon fill color to white if par("bg") is "transparent". This 
works okay for most displays, and for hard copy.

Jim



More information about the R-help mailing list