[R] histogram loses top row with alpha transparency under Windows
k.ponting at aurix.com
Tue Oct 14 13:39:20 CEST 2008
Thankyou for your response.
> From: Prof Brian Ripley [mailto:ripley at stats.ox.ac.uk]
> Sent: 14 October 2008 12:09
> To: Keith Ponting
> Cc: Richard.Cotton at hsl.gov.uk; r-help at r-project.org
> Subject: Re: [R] histogram loses top row with alpha transparency under
> I *presume* this is the windows() device in a current version of R,
> you failed to tell us almost any of the information requested in the
> posting guide.
Yes, it is the windows() device in R 2.7.1 and also R version 2.8.0 beta
I very much appreciate the heroic efforts of you and the other core 'R'
in answering so many e-mails on the list, and also your frustration with
posters who do not supply information, but in my defence I must point
that you appear to have only received my second message on this subject
first one (Message 18 in R-help Digest, Vol 68, Issue 9, to which
Cotton replied) gave (I hope) all the information requested.
> If so, you are seeing how Windows GDI copying operations work: if the
> region to be copied goes off-window, they clip the region completely.
> Your example works in R-devel, and if that survives a few weeks of
> testing, I might port the workaround to 2.8.1. (A similar fix in
> patched ended up with undesirable side effects in 2.7.2, so careful
> testing is needed.)
> Implementing semi-transparent colours on windows() was hard, and it
> would be nice to see some appreciation of the effort involved.
Once I had found the clipping work-around the results are exactly what I
needed - semi-transparent colours are wonderful!!
> On Fri, 10 Oct 2008, Keith Ponting wrote:
> > Richard.Cotton wrote:
> >> The rectangles being drawn extend higher than the top of the panel.
> > (Your y
> >> axis ranges from 0 to 50, but the bars go up to 100.)
> > Thankyou - I can also make the bars on the lower panels vanish by
> > tinkering with ylim.
> >> In the top row of plots, depending upon the shape of your device
> > window, the
> >> bars can extend beyond the range of the device window. For some
> > reason,
> >> (take a look in panel.rect), when you specify alpha less than 1,
> >> prevents the bar being drawn.
> > The problem lies deeper. I can demonstrate the same effect with raw
> > grid calls (but cannot find a way into "grid.draw" to see what is
> going on):
> > cols <- rainbow(2,alpha=0.5)
> > library(grid)
> > grid.newpage()
> > pushViewport(plotViewport(c(5,4,2,2)))
> > # draw viewport limits:
> > grid.rect()
> > # VISIBLE: small projection outside viewport, transparent fill and
> > edge
> > th
> > =unit(0.18,"npc"),x=0.1)
> > # VISIBLE: small projection outside viewport, standard colours fill
> > and edge
> > npc"),x=0.3)
> > # INVISIBLE: larger projection outside viewport, transparent colours
> > fill and edge
> > th
> > =unit(0.18,"npc"),x=0.5)
> > # VISIBLE: larger projection outside viewport, standard colours fill
> > and edge
> > npc"),x=0.7)
> > # MIXED: larger projection outside viewport, standard colour edge
> > visible, transparent fill not
> > t(
> > 0.18,"npc"),x=0.9)
> > I can also show the same effect using standard graphics calls:
> > par(xpd=NA)
> > plot(c(1,2))
> > rect(1.01,1,1.19,2.2,border=cols,col=cols)
> > rect(1.21,1,1.39,2.2,border=3,col=2)
> > rect(1.41,1,1.59,4,border=cols,col=cols)
> > rect(1.61,1,1.79,4,border=3,col=2)
> > rect(1.81,1,1.99,4,border=3,col=cols)
> > Both of these examples have missing alpha transparency colours under
> > Windows but produce the expected filled rectangles under Linux.
> >> You need to add type="count" to the call to histogram, or rescale
> > bar
> >> heights.
> > My post was a rather simplified example - I am actually trying to
> > visible a "small" distribution on the skirt of a large one, which
> > means that scaling the bar heights is not sufficient. I have worked
> > around the problem by modifying panel.histogram to _clip_ the bar
> > Keith
> > Keith Ponting
> > Aurix Ltd, Malvern WR14 3SZ UK
> > ______________________________________________
> > R-help at r-project.org 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
Aurix Ltd, Malvern WR14 3SZ UK
More information about the R-help