[R] making scatter plot points fill semi-transparent

Felipe Carrillo mazatlanmexico at yahoo.com
Thu Aug 6 16:19:12 CEST 2009


You can also use ggplot2:

library(ggplot2)
x <- rnorm(10000);y <- rnorm(x);myplot <- data.frame(x,y)
qplot(x,y,data= myplot,colour=I(alpha("blue",1/25)))


Felipe D. Carrillo  
Supervisory Fishery Biologist  
Department of the Interior  
US Fish & Wildlife Service  
California, USA


--- On Wed, 8/5/09, Gabor Grothendieck <ggrothendieck at gmail.com> wrote:

> From: Gabor Grothendieck <ggrothendieck at gmail.com>
> Subject: Re: [R] making scatter plot points fill semi-transparent
> To: "per freem" <perfreem at gmail.com>
> Cc: r-help at r-project.org
> Date: Wednesday, August 5, 2009, 9:13 PM
> Lattice graphics can do that:
> 
> library(lattice)
> xyplot(0:20 ~ 0:20, alpha = 0:20/20, col = "red", pch = 19,
> cex = 5)
> 
> Google for
>   HTML colors
> to find out more about the hex codes you are referring to.
> 
> On Wed, Aug 5, 2009 at 11:48 PM, per freem<perfreem at gmail.com>
> 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. is there
> any way to pass
> > in the usual col="colorname" argument and then tweak
> that color's
> > transparency?
> >
> > thank you.
> >
> > https://stat.ethz.ch/pipermail/r-help/2007-October/142934.html
> >
> > ______________________________________________
> > 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.
> >
> 
> ______________________________________________
> 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.
> 







More information about the R-help mailing list