Karl Ove Hufthammer
2008-Apr-22 14:22 UTC
[R] Getting rid of borders on semi-transparent plotting symbols
R version 2.7.0 RC (2008-04-20 r45403) When using semi-transparent filled plotting symbols, the border of the symbol has a different (darker) colour than the interior: plot(0, 0, pch=19, col="#FF000022") (Saving this as a PDF and looking at it magnified may make it easier to see.) This is pretty annoying, since when plotting partially overlapping points, the border colour dominates, making the colour of overlapping points more saturated than they should be. This isn't so much of a problem when using very large values of 'cex', since the width of the border is constant, and doesn't vary with cex. But with small values (and the default value) of cex, it's very visible. I thought this maybe could be solved by using pch=21 instead of pch=19, and setting the 'bg' colour to the same colour as 'col', like this. plot(0, 0, pch=21, col="#FF000022", bg="#FF000022") But this has no effect. 'bg' *does* set the background (interior) colour (this is easy to check by using a different colour), but not the border colour, which is determined by 'col' alone. So I guess in theory I can get the border and interior the same colour by setting 'col' to a ligher colour than the one I actually want to use, and then set the 'bg' colour to the one I want to use. But how should I select the lighter colour so that the darker version (i.e., the border colour) is the one I want? Frankly, the current behaviour feels much more like a bug than a feature. If I set pch=19, I want a completely filled circle, even if my chosen colour is partially transparent. I'm using R version 2.7.0 RC (2008-04-20 r45403) i686-pc-linux-gnu -- Karl Ove Hufthammer
Prof Brian Ripley
2008-Apr-22 15:47 UTC
[R] Getting rid of borders on semi-transparent plotting symbols
plot(0, 0, pch=21, bg="#FF000022", col="#FF000001") may be (close to) what you are looking for. On Tue, 22 Apr 2008, Karl Ove Hufthammer wrote:> R version 2.7.0 RC (2008-04-20 r45403) > > When using semi-transparent filled plotting symbols, the border of the > symbol has a different (darker) colour than the interior: > > plot(0, 0, pch=19, col="#FF000022") > > (Saving this as a PDF and looking at it magnified may make it easier to > see.) > > This is pretty annoying, since when plotting partially overlapping > points, the border colour dominates, making the colour of overlapping > points more saturated than they should be. > > This isn't so much of a problem when using very large values of 'cex', > since the width of the border is constant, and doesn't vary with cex. > But with small values (and the default value) of cex, it's very visible. > > I thought this maybe could be solved by using pch=21 instead of pch=19, > and setting the 'bg' colour to the same colour as 'col', like this. > > plot(0, 0, pch=21, col="#FF000022", bg="#FF000022") > > But this has no effect. 'bg' *does* set the background (interior) colour > (this is easy to check by using a different colour), but not the border > colour, which is determined by 'col' alone. > > So I guess in theory I can get the border and interior the same colour by > setting 'col' to a ligher colour than the one I actually want to use, > and then set the 'bg' colour to the one I want to use. But how should I > select the lighter colour so that the darker version (i.e., the border > colour) is the one I want? > > Frankly, the current behaviour feels much more like a bug than a feature. > If I set pch=19, I want a completely filled circle, even if my chosen > colour is partially transparent. > > I'm using > R version 2.7.0 RC (2008-04-20 r45403) > i686-pc-linux-gnu > > -- > Karl Ove Hufthammer > > ______________________________________________ > 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
Dieter Menne
2008-Apr-22 18:05 UTC
[R] Getting rid of borders on semi-transparent plotting symbols
Karl Ove Hufthammer <Karl.Hufthammer <at> math.uib.no> writes:> > R version 2.7.0 RC (2008-04-20 r45403) > > When using semi-transparent filled plotting symbols, the border of the > symbol has a different (darker) colour than the interior: > > plot(0, 0, pch=19, col="#FF000022") >Same R version, Window, the problem turn up on-screen, but not when I do pdf() plot(0, 0, pch=19, col="#FF000022") dev.off() Dieter