erasing an area of a graph

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

erasing an area of a graph

Therneau, Terry M., Ph.D.
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.

______________________________________________
[hidden email] mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.
Reply | Threaded
Open this post in threaded view
|

Re: erasing an area of a graph

Thomas Lumley


I don't think this is possible.   With an opaque background you can get back the background color just by overwriting, but any additional painting can only increase the opacity so you can't get back to transparent.

    -thomas

On Thu, 8 Apr 2010, 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.
>
> ______________________________________________
> [hidden email] mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>

Thomas Lumley Assoc. Professor, Biostatistics
[hidden email] University of Washington, Seattle

______________________________________________
[hidden email] mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.
Reply | Threaded
Open this post in threaded view
|

Re: erasing an area of a graph

Jim Lemon
In reply to this post by Therneau, Terry M., Ph.D.
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

______________________________________________
[hidden email] mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.