[Distr-commits] r856 - branches/distr-2.5/pkg/distrMod branches/distr-2.5/pkg/distrMod/R branches/distr-2.5/pkg/distrMod/man pkg/distrMod pkg/distrMod/R pkg/distrMod/man

noreply at r-forge.r-project.org noreply at r-forge.r-project.org
Sat Jan 12 03:58:42 CET 2013


Author: ruckdeschel
Date: 2013-01-12 03:58:38 +0100 (Sat, 12 Jan 2013)
New Revision: 856

Added:
   branches/distr-2.5/pkg/distrMod/R/alphaTransp.R
   branches/distr-2.5/pkg/distrMod/man/addAlphTrsp2col.Rd
   pkg/distrMod/R/alphaTransp.R
   pkg/distrMod/man/addAlphTrsp2col.Rd
Modified:
   branches/distr-2.5/pkg/distrMod/NAMESPACE
   branches/distr-2.5/pkg/distrMod/R/qqplot.R
   branches/distr-2.5/pkg/distrMod/man/qqplot.Rd
   pkg/distrMod/NAMESPACE
   pkg/distrMod/R/qqplot.R
   pkg/distrMod/man/qqplot.Rd
Log:
distrMod: helper function addAlphTrsp2col committed; qqplot gains argument alpha.trsp to control for alpha transparency

Modified: branches/distr-2.5/pkg/distrMod/NAMESPACE
===================================================================
--- branches/distr-2.5/pkg/distrMod/NAMESPACE	2013-01-11 06:58:10 UTC (rev 855)
+++ branches/distr-2.5/pkg/distrMod/NAMESPACE	2013-01-12 02:58:38 UTC (rev 856)
@@ -83,3 +83,4 @@
 export("NormScaleUnknownLocationFamily", "NormLocationUnknownScaleFamily")
 export("L2LocationUnknownScaleFamily", "L2ScaleUnknownLocationFamily")
 export("meRes", "get.criterion.fct")
+export("addAlphTrsp2col")

Added: branches/distr-2.5/pkg/distrMod/R/alphaTransp.R
===================================================================
--- branches/distr-2.5/pkg/distrMod/R/alphaTransp.R	                        (rev 0)
+++ branches/distr-2.5/pkg/distrMod/R/alphaTransp.R	2013-01-12 02:58:38 UTC (rev 856)
@@ -0,0 +1,5 @@
+### add alpha.transparency to given color
+
+addAlphTrsp2col <- function(col, alpha=255){
+   do.call(rgb,as.list(c(col2rgb(col)[,1],max=255,alpha=alpha)))
+}

Modified: branches/distr-2.5/pkg/distrMod/R/qqplot.R
===================================================================
--- branches/distr-2.5/pkg/distrMod/R/qqplot.R	2013-01-11 06:58:10 UTC (rev 855)
+++ branches/distr-2.5/pkg/distrMod/R/qqplot.R	2013-01-12 02:58:38 UTC (rev 856)
@@ -85,6 +85,7 @@
              cex.lbl = par("cex"),## magnification factor for the plotted observation labels
              col.lbl = par("col"),## color for the plotted observation labels
              adj.lbl = NULL,      ## adj parameter for the plotted observation labels
+             alpha.trsp = NA,     ## alpha transparency to be added afterwards
              jit.fac = 0,         ## jittering factor used for discrete distributions
              check.NotInSupport = TRUE, ## shall we check if all x lie in support(y)
              col.NotInSupport = "red", ## if preceding check TRUE color of x if not in support(y)
@@ -120,10 +121,14 @@
     if("support" %in% names(getSlots(class(y))))
        yc <- sort(jitter(yc, factor=jit.fac))
 
+    alp.v <- .makeLenAndOrder(alpha.trsp,ord.x)
+    alp.t <- function(x,a1) if(is.na(x)) x else addAlphTrsp2col(x,a1)
+    alp.f <- if(length(alpha.trsp)==1L && is.na(alpha.trsp))
+             function(x,a) x else function(x,a) mapply(x,alp.t,a1=a)
     cex.pch <- .makeLenAndOrder(cex.pch,ord.x)
     cex.lbl <- .makeLenAndOrder(cex.lbl,ord.x)
-    col.pch <- .makeLenAndOrder(col.pch,ord.x)
-    col.lbl <- .makeLenAndOrder(col.lbl,ord.x)
+    col.pch <- alp.f(.makeLenAndOrder(col.pch,ord.x),alp.v)
+    col.lbl <- alp.f(.makeLenAndOrder(col.lbl,ord.x),alp.v)
 
     if(withLab){
       if(is.null(lab.pts)) lab.pts <- paste(ord.x)

Added: branches/distr-2.5/pkg/distrMod/man/addAlphTrsp2col.Rd
===================================================================
--- branches/distr-2.5/pkg/distrMod/man/addAlphTrsp2col.Rd	                        (rev 0)
+++ branches/distr-2.5/pkg/distrMod/man/addAlphTrsp2col.Rd	2013-01-12 02:58:38 UTC (rev 856)
@@ -0,0 +1,24 @@
+\name{addAlphTrsp2col}
+\alias{addAlphTrsp2col}
+
+\title{"addAlphTrsp2col"}
+\description{Adds alpha transparency to a given color.}
+\usage{addAlphTrsp2col(col, alpha=255)}
+\arguments{
+  \item{col}{any valid color}
+  \item{alpha}{tranparancy; an integer value in [0,255]}
+}
+\value{a color in rgb coordinates}
+%\references{}
+\author{Peter Ruckdeschel \email{Peter.Ruckdeschel at itwm.fraunhofer.de}}
+%\note{}
+\examples{
+  addAlphTrsp2col(rgb(1,0.3,0.03), 25)
+  addAlphTrsp2col("darkblue", 25)
+  addAlphTrsp2col("#AAAAAAAA",25)
+  palette(rainbow(6))
+  addAlphTrsp2col(2, 25)
+}
+\keyword{distribution}
+\concept{S4 distribution class}
+

Modified: branches/distr-2.5/pkg/distrMod/man/qqplot.Rd
===================================================================
--- branches/distr-2.5/pkg/distrMod/man/qqplot.Rd	2013-01-11 06:58:10 UTC (rev 855)
+++ branches/distr-2.5/pkg/distrMod/man/qqplot.Rd	2013-01-12 02:58:38 UTC (rev 856)
@@ -18,7 +18,8 @@
     cex.sCI = par("cex"),
     cex.pch = par("cex"), col.pch = par("col"),
     cex.lbl = par("cex"), col.lbl = par("col"), adj.lbl = NULL,
-    jit.fac = 0, check.NotInSupport = TRUE, col.NotInSupport = "red",
+    alpha.trsp = NA, jit.fac = 0,
+    check.NotInSupport = TRUE, col.NotInSupport = "red",
     with.legend = TRUE, legend.bg = "white",
     legend.pos = "topleft", legend.cex = 0.8, 
     legend.pref = "", legend.postf = "",  legend.alpha = alpha.CI)
@@ -87,6 +88,14 @@
 \item{cex.lbl}{magnification factor for the plotted observation labels}
 \item{col.lbl}{color for the plotted observation labels}
 \item{adj.lbl}{adj parameter for the plotted observation labels}
+\item{alpha.trsp}{alpha transparency to be added ex post to colors
+        \code{col.pch} and \code{col.lbl}; if one-dim and NA all colors are
+        left unchanged. Otherwise, with usual recycling rules \code{alpha.trsp}
+        gets shorted/prolongated to length the data-symbols to be plotted.
+        Coordinates of this vector \code{alpha.trsp} with NA are left unchanged,
+        while for the remaining ones, the alpha channel in rgb space is set
+        to the respective coordinate value of \code{alpha.trsp}. The non-NA
+        entries must be integers in [0,255] (0 invisible, 255 opaque).}
 \item{jit.fac}{jittering factor used for discrete distributions}
 \item{check.NotInSupport}{logical; shall we check if all \code{x}-quantiles lie
 in \code{support(y)}?}

Modified: pkg/distrMod/NAMESPACE
===================================================================
--- pkg/distrMod/NAMESPACE	2013-01-11 06:58:10 UTC (rev 855)
+++ pkg/distrMod/NAMESPACE	2013-01-12 02:58:38 UTC (rev 856)
@@ -83,3 +83,4 @@
 export("NormScaleUnknownLocationFamily", "NormLocationUnknownScaleFamily")
 export("L2LocationUnknownScaleFamily", "L2ScaleUnknownLocationFamily")
 export("meRes", "get.criterion.fct")
+export("addAlphTrsp2col")

Added: pkg/distrMod/R/alphaTransp.R
===================================================================
--- pkg/distrMod/R/alphaTransp.R	                        (rev 0)
+++ pkg/distrMod/R/alphaTransp.R	2013-01-12 02:58:38 UTC (rev 856)
@@ -0,0 +1,5 @@
+### add alpha.transparency to given color
+
+addAlphTrsp2col <- function(col, alpha=255){
+   do.call(rgb,as.list(c(col2rgb(col)[,1],max=255,alpha=alpha)))
+}

Modified: pkg/distrMod/R/qqplot.R
===================================================================
--- pkg/distrMod/R/qqplot.R	2013-01-11 06:58:10 UTC (rev 855)
+++ pkg/distrMod/R/qqplot.R	2013-01-12 02:58:38 UTC (rev 856)
@@ -85,6 +85,7 @@
              cex.lbl = par("cex"),## magnification factor for the plotted observation labels
              col.lbl = par("col"),## color for the plotted observation labels
              adj.lbl = NULL,      ## adj parameter for the plotted observation labels
+             alpha.trsp = NA,     ## alpha transparency to be added afterwards
              jit.fac = 0,         ## jittering factor used for discrete distributions
              check.NotInSupport = TRUE, ## shall we check if all x lie in support(y)
              col.NotInSupport = "red", ## if preceding check TRUE color of x if not in support(y)
@@ -120,10 +121,14 @@
     if("support" %in% names(getSlots(class(y))))
        yc <- sort(jitter(yc, factor=jit.fac))
 
+    alp.v <- .makeLenAndOrder(alpha.trsp,ord.x)
+    alp.t <- function(x,a1) if(is.na(x)) x else addAlphTrsp2col(x,a1)
+    alp.f <- if(length(alpha.trsp)==1L && is.na(alpha.trsp))
+             function(x,a) x else function(x,a) mapply(x,alp.t,a1=a)
     cex.pch <- .makeLenAndOrder(cex.pch,ord.x)
     cex.lbl <- .makeLenAndOrder(cex.lbl,ord.x)
-    col.pch <- .makeLenAndOrder(col.pch,ord.x)
-    col.lbl <- .makeLenAndOrder(col.lbl,ord.x)
+    col.pch <- alp.f(.makeLenAndOrder(col.pch,ord.x),alp.v)
+    col.lbl <- alp.f(.makeLenAndOrder(col.lbl,ord.x),alp.v)
 
     if(withLab){
       if(is.null(lab.pts)) lab.pts <- paste(ord.x)

Added: pkg/distrMod/man/addAlphTrsp2col.Rd
===================================================================
--- pkg/distrMod/man/addAlphTrsp2col.Rd	                        (rev 0)
+++ pkg/distrMod/man/addAlphTrsp2col.Rd	2013-01-12 02:58:38 UTC (rev 856)
@@ -0,0 +1,24 @@
+\name{addAlphTrsp2col}
+\alias{addAlphTrsp2col}
+
+\title{"addAlphTrsp2col"}
+\description{Adds alpha transparency to a given color.}
+\usage{addAlphTrsp2col(col, alpha=255)}
+\arguments{
+  \item{col}{any valid color}
+  \item{alpha}{tranparancy; an integer value in [0,255]}
+}
+\value{a color in rgb coordinates}
+%\references{}
+\author{Peter Ruckdeschel \email{Peter.Ruckdeschel at itwm.fraunhofer.de}}
+%\note{}
+\examples{
+  addAlphTrsp2col(rgb(1,0.3,0.03), 25)
+  addAlphTrsp2col("darkblue", 25)
+  addAlphTrsp2col("#AAAAAAAA",25)
+  palette(rainbow(6))
+  addAlphTrsp2col(2, 25)
+}
+\keyword{distribution}
+\concept{S4 distribution class}
+

Modified: pkg/distrMod/man/qqplot.Rd
===================================================================
--- pkg/distrMod/man/qqplot.Rd	2013-01-11 06:58:10 UTC (rev 855)
+++ pkg/distrMod/man/qqplot.Rd	2013-01-12 02:58:38 UTC (rev 856)
@@ -18,7 +18,8 @@
     cex.sCI = par("cex"),
     cex.pch = par("cex"), col.pch = par("col"),
     cex.lbl = par("cex"), col.lbl = par("col"), adj.lbl = NULL,
-    jit.fac = 0, check.NotInSupport = TRUE, col.NotInSupport = "red",
+    alpha.trsp = NA, jit.fac = 0,
+    check.NotInSupport = TRUE, col.NotInSupport = "red",
     with.legend = TRUE, legend.bg = "white",
     legend.pos = "topleft", legend.cex = 0.8, 
     legend.pref = "", legend.postf = "",  legend.alpha = alpha.CI)
@@ -87,6 +88,14 @@
 \item{cex.lbl}{magnification factor for the plotted observation labels}
 \item{col.lbl}{color for the plotted observation labels}
 \item{adj.lbl}{adj parameter for the plotted observation labels}
+\item{alpha.trsp}{alpha transparency to be added ex post to colors
+        \code{col.pch} and \code{col.lbl}; if one-dim and NA all colors are
+        left unchanged. Otherwise, with usual recycling rules \code{alpha.trsp}
+        gets shorted/prolongated to length the data-symbols to be plotted.
+        Coordinates of this vector \code{alpha.trsp} with NA are left unchanged,
+        while for the remaining ones, the alpha channel in rgb space is set
+        to the respective coordinate value of \code{alpha.trsp}. The non-NA
+        entries must be integers in [0,255] (0 invisible, 255 opaque).}
 \item{jit.fac}{jittering factor used for discrete distributions}
 \item{check.NotInSupport}{logical; shall we check if all \code{x}-quantiles lie
 in \code{support(y)}?}



More information about the Distr-commits mailing list