[R] Unwanted white borders on semi-transparent polygons?

Prof Brian Ripley ripley at stats.ox.ac.uk
Fri Apr 27 13:58:05 CEST 2007


The posting guide says

   For questions about unexpected behavior or a possible bug, you should,
   at a minimum, copy and paste the output from sessionInfo() into your message.

   If you are using an old version of R and think it does not work
   properly, upgrade to the latest version and try that, before posting.

[There is a known bug in 2.4.0 related to semi-transparency, fixed in 
2.4.0.  I would not have attempted to answer a question about 2.1.1, and 
we do rely on people seeking free technical assistance doing their bit.]


On Fri, 27 Apr 2007, Matthew Neilson wrote:

> Thanks for your fast response.
>
> I'm using R version 2.1.1 on OS X 10.3.9 to create the pdfs. I have tried viewing the pdf output in both Acrobat 6 and 7 (both display a white border around each polygon) as well as
> Preview (displays fine). I have emailed the pdf file to some correspondents running Windows, and they also see white borders when viewing with Acrobat (version unspecified).
>
> I have tried using R version 2.4.0 on a G5 machine (which I can access remotely) running OS X 10.4.8, but the resulting pdf renders incorrectly (i.e. with a white border around each
> polygon) in both Acrobat *and* Preview. So it would appear that the combination of R 2.1.1 and OS X 10.3.9 gives slightly better results - although plots still appear incorrect when
> printed or viewed in Acrobat.
>
> Unfortunately, I don't have access to a Windows machine to test this out. Even if I did, many of my scripts include various Unix system calls so I don't think that would be a viable
> solution. Could this be a bug in the OS X pdf driver?

The R pdf() device is the same on all platforms.

> Many thanks,
>
>
> -Matt
>
>
>
> On 27 Apr 2007, at 06:42, Prof Brian Ripley wrote:
>
>> 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
>>>
>>> pdf(file="test.pdf",version="1.4")
>>> plot(0,0,type="l",ylim=range(-3,3),xlim=range(-1,5))
>>> 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),
>>> border=NA)
>>> 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),
>>> border=NA)
>>> dev.off()
>>>
>>> # 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,
>>>
>>>
>>> -Matt
>>>
>>
>> --
>> 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
>
> ______________________________________________
> R-help at stat.math.ethz.ch 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.
>

-- 
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 mailing list