Hi,

On Aug 5, 2009, at 11:48 PM, per freem wrote:

hi all,

i have a simple scatter plot, and i'd like to make it so the scatter
plot colors are slightly transparent. i see in a previous post that
someone mentioned the "alpha" parameter, but i am not sure how it can
be used with the 'plot' function [*].

for example, suppose i have:

plot(mydata$column1, mydata$column2, col="red", cex=1)

i now want to make it so the color of these points (in this case red)
is slightly transparent, which will make overlap between them very
obvious. i realize that hexbin and other density plot methods are used
to make this, but i am using it for a different purpose, and so i just
want the points to be transparent without any binning or shading.

a previous poster suggested:

plot( rnorm(1000), rnorm(1000), col="#0000ff22", pch=16,cex=3)

but i don't understand this color notation.

It's the usual #RRGGBB color notation, w/ the last two digits apparently defining the amount of opacity.

#0000FFFF is blue w/ full opacity

To figure out how to define your color with RGB notation, use a mix of col2rgb and rgb functions:

R> col2rgb('blue', alpha=T)
      [,1]
red      0
green    0
blue   255
alpha  255

R> rgb(red=0, green=0, blue=255, alpha=255, max=255)
[1] "#0000FFFF"

Play with different values of alpha (0 < alpha <= 255) in the above call to get different levels of opacity for your points.

R> rgb(red=0, green=0, blue=255, alpha=10, max=255)
[1] "#0000FF0A"

R> plot( rnorm(1000), rnorm(1000), col="#0000FF0A", pch=16,cex=3)

 is there any way to pass
in the usual col="colorname" argument and then tweak that color's
transparency?

Maybe, but I'm not familiar with it.

-steve

--
Steve Lianoglou
Graduate Student: Computational Systems Biology
  |  Memorial Sloan-Kettering Cancer Center
  |  Weill Medical College of Cornell University
Contact Info: http://cbio.mskcc.org/~lianos/contact

______________________________________________
R-help@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.

Reply via email to