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

Prof Brian Ripley ripley at stats.ox.ac.uk
Tue Apr 22 17:47:49 CEST 2008


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



More information about the R-help mailing list