[R] Unwanted white borders on semi-transparent polygons?
Prof Brian Ripley
ripley at stats.ox.ac.uk
Fri Apr 27 07:42:46 CEST 2007
What version of R, what OS, what version of Acrobat?
I don't see this in 2.5.0 on Windows (using Acrobat 7: Acrobat does not
exist on Linux, AFAIK). And reading the PDF produced shows no sign of an
extra object for the border.
On Fri, 27 Apr 2007, Matthew Neilson wrote:
> Hey all,
> I'm trying to create a plot of two semi-transparent regions. The reason they need to be partially transparent is so that I can see if there's any overlap. Here's some example code:
> # BEGIN
> polygon(c(0,1,2,3,4,3,2,1,0), c(0,1,2,1,0,-1,-2,-1,0), col=rgb(1,0,0,0.5),
> polygon(c(1,2,3,4,5,4,3,2,1), c(0,1,2,1,0,-1,-2,-1,0), col=rgb(0,0,1,0.5),
> # END
> The problem with this is that, despite setting "border = NA", I get a
> big white border surrounding each polygon!! Funnily enough, setting the
> alpha channel equal to 1 (as opposed to 0.5) *doesn't* give the border,
> but an alpha channel of 1 produces an opaque polygon! :S
> I have read the FAQ, and (unfortunately) turning off line-art smoothing
> does not give the desired effect. Furthermore, my pdfs print with a
> white border surrounding each transparent polygon.
> Now, here comes the really bizarre part. Whilst Adobe Acrobat displays
> the unwanted white border, Apple Preview respects the "border=NA"
> argument and shows the two diamonds as they are intended. However,
> opening up the pdf in Illustrator CS reveals that there is in fact a
> transparent (according to Illustrator) border *on top* of each diamond.
> Deleting these two borders (one for each polygon) and re-saving the pdf
> appears to correct the issue. So the obvious question is: how did the
> surrounding borders get there in the first place? A bug in the polygon
> function, perhaps?
> Does anyone have any ideas for preventing these unwanted borders around
> semi-transparent polygons (without having to resort to Illustrator)? Has
> anyone else even come across this problem?
> Many thanks,
Brian D. Ripley, ripley at stats.ox.ac.uk
Professor of Applied Statistics, http://www.stats.ox.ac.uk/~ripley/
University of Oxford, Tel: +44 1865 272861 (self)
1 South Parks Road, +44 1865 272866 (PA)
Oxford OX1 3TG, UK Fax: +44 1865 272595
More information about the R-help