[R] Getting rid of borders on semi-transparent plotting symbols

Karl Ove Hufthammer Karl.Hufthammer at math.uib.no
Tue Apr 22 16:22:55 CEST 2008


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



More information about the R-help mailing list