[Distr-commits] r600 - in branches/distr-2.2/pkg: distr/R distr/inst/doc distr/man distrMod/R distrMod/man

noreply at r-forge.r-project.org noreply at r-forge.r-project.org
Tue Oct 6 13:52:30 CEST 2009


Author: ruckdeschel
Date: 2009-10-06 13:52:29 +0200 (Tue, 06 Oct 2009)
New Revision: 600

Modified:
   branches/distr-2.2/pkg/distr/R/internals-qqplot.R
   branches/distr-2.2/pkg/distr/R/qqplot.R
   branches/distr-2.2/pkg/distr/inst/doc/Rplots.pdf
   branches/distr-2.2/pkg/distr/man/internals-qqplot.Rd
   branches/distr-2.2/pkg/distr/man/qqplot.Rd
   branches/distr-2.2/pkg/distrMod/R/qqplot.R
   branches/distr-2.2/pkg/distrMod/man/qqplot.Rd
Log:
qqplot: yet another enhancement: legend parameters may be set from qqplot;
and: if discrete, corresponding symbols instead of lines appear in legend.

Modified: branches/distr-2.2/pkg/distr/R/internals-qqplot.R
===================================================================
--- branches/distr-2.2/pkg/distr/R/internals-qqplot.R	2009-10-06 11:11:49 UTC (rev 599)
+++ branches/distr-2.2/pkg/distr/R/internals-qqplot.R	2009-10-06 11:52:29 UTC (rev 600)
@@ -186,7 +186,9 @@
 .confqq <- function(x,D, withConf.pw  = TRUE,  withConf.sim = TRUE, alpha,
                     col.pCI, lty.pCI, lwd.pCI, pch.pCI, cex.pCI,
                     col.sCI, lty.sCI, lwd.sCI, pch.sCI, cex.sCI,
-                    n,exact.sCI=(n<100),exact.pCI=(n<100), nosym.pCI = FALSE){
+                    n,exact.sCI=(n<100),exact.pCI=(n<100), nosym.pCI = FALSE,
+                    with.legend = TRUE, legend.bg = "white",
+                    legend.pos = "topleft", legend.cex = 0.8){
 
    x <- sort(unique(x))
    if("gaps" %in% names(getSlots(class(D))))
@@ -234,37 +236,43 @@
                 col=col.sCI, pch=pch.sCI, cex = cex.sCI)
       }
    }
-   if( qqb$err["pw"] ||  qqb$err["sim"] ){
-      expression1 <- substitute(
-         nosym0~"pointw."~ex.p~alpha==alpha0~"%- conf. interval",
-         list(ex.p = if(exact.pCI) "exact" else "asympt.",
-              alpha0 = alpha*100,
-              nosym0 = if(nosym.pCI&&exact.pCI) "shortest asymm." else "symm"))
-      expression2 <- substitute(
-         "simult."~ex.s~alpha==alpha0~"%- conf. interval",
-         list(ex.s = if(exact.sCI) "exact" else "asympt.",
-              alpha0 = alpha*100))
-      if(!qqb$err["sim"]){
-         expression3 <- expression1
-         pch0 <- if(sum(!SI.c)>0) pch.pCI else 0
-         lty0 <- if(sum(SI.c)>0)  lty.pCI else 0
-         col0 <- col.pCI
+   if(with.legend){
+      if( qqb$err["pw"] ||  qqb$err["sim"] ){
+         expression1 <- substitute(
+            nosym0~"pointw."~ex.p~alpha==alpha0~"%- conf. interval",
+            list(ex.p = if(exact.pCI) "exact" else "asympt.",
+                 alpha0 = alpha*100,
+                 nosym0 = if(nosym.pCI&&exact.pCI) "shortest asymm." else "symm"))
+         expression2 <- substitute(
+            "simult."~ex.s~alpha==alpha0~"%- conf. interval",
+            list(ex.s = if(exact.sCI) "exact" else "asympt.",
+                 alpha0 = alpha*100))
+
+         lcl <- list()
+         if(!qqb$err["sim"]){
+            expression3 <- expression1
+            lcl$pch <- if(sum(!SI.c)>0) pch.pCI else NULL
+            lcl$lty <- if(sum(SI.c)>0)  lty.pCI else NULL
+            lcl$col <- col.pCI
+            lcl$lwd <- if(sum(SI.c)>0)  2 else NULL
+         }
+         if(!qqb$err["pw"]){
+            expression3 <- expression2
+            lcl$pch <- if(sum(!SI.c)>0) pch.sCI else NULL
+            lcl$lty <- if(sum(SI.c)>0)  lty.sCI else NULL
+            lcl$col <- col.sCI
+            lcl$lwd <- if(sum(SI.c)>0)  2 else NULL
+         }
+         if( qqb$err["pw"] && qqb$err["sim"]){
+            expression3 <- eval(substitute(expression(expression1, expression2)))
+            lcl$pch <- if(sum(!SI.c)>0) c(pch.pCI, pch.sCI) else NULL
+            lcl$lty <- if(sum(SI.c)>0)  c(lty.pCI, lty.sCI) else NULL
+            lcl$col <- c(col.pCI,col.sCI)
+            lcl$lwd <- if(sum(SI.c)>0)  2 else NULL
+         }
+         do.call(legend, c(list(legend.pos, legend = expression3, bg = legend.bg,
+                                merge = FALSE, cex = legend.cex), lcl))
       }
-      if(!qqb$err["pw"]){
-         expression3 <- expression2
-         pch0 <- if(sum(!SI.c)>0) pch.sCI else 0
-         lty0 <- if(sum(SI.c)>0)  lty.sCI else 0
-         col0 <- col.sCI
-      }
-      if( qqb$err["pw"] && qqb$err["sim"]){
-         expression3 <- eval(substitute(expression(expression1, expression2)))
-         pch0 <- if(sum(!SI.c)>0) c(pch.pCI, pch.sCI) else 0
-         lty0 <- if(sum(SI.c)>0)  c(lty.pCI, lty.sCI) else 0
-         col0 <- c(col.pCI,col.sCI)
-      }
-      legend("topleft", legend = expression3, bg = "white",
-              lty = lty0, pch = pch0, merge= FALSE, col = col0,
-              lwd = 2, cex = .8)
    }
   return(invisible(NULL))
 }

Modified: branches/distr-2.2/pkg/distr/R/qqplot.R
===================================================================
--- branches/distr-2.2/pkg/distr/R/qqplot.R	2009-10-06 11:11:49 UTC (rev 599)
+++ branches/distr-2.2/pkg/distr/R/qqplot.R	2009-10-06 11:52:29 UTC (rev 600)
@@ -16,7 +16,8 @@
     col.sCI = "tomato2", lty.sCI = 4, lwd.sCI = 2, pch.sCI = par("pch"), cex.sCI = par("cex"),
     cex.pch = par("cex"), col.pch = par("col"),
     jit.fac = 0, check.NotInSupport = TRUE,
-    col.NotInSupport = "red"){
+    col.NotInSupport = "red", with.legend = TRUE, legend.bg = "white",
+    legend.pos = "topleft", legend.cex = 0.8){
 
     mc <- match.call(call = sys.call(sys.parent(1)))
     if(missing(xlab)) mc$xlab <- as.character(deparse(mc$x))
@@ -97,7 +98,9 @@
                       col.pCI, lty.pCI, lwd.pCI, pch.pCI, cex.pCI,
                       col.sCI, lty.sCI, lwd.sCI, pch.sCI, cex.sCI,
                   n, exact.sCI = exact.sCI, exact.pCI = exact.pCI,
-                  nosym.pCI = nosym.pCI)
+                  nosym.pCI = nosym.pCI, with.legend = with.legend,
+                  legend.bg = legend.bg, legend.pos = legend.pos,
+                  legend.cex = legend.cex)
        }
     }
     return(ret)

Modified: branches/distr-2.2/pkg/distr/inst/doc/Rplots.pdf
===================================================================
--- branches/distr-2.2/pkg/distr/inst/doc/Rplots.pdf	2009-10-06 11:11:49 UTC (rev 599)
+++ branches/distr-2.2/pkg/distr/inst/doc/Rplots.pdf	2009-10-06 11:52:29 UTC (rev 600)
@@ -2,8 +2,8 @@
 %âãÏÓ\r
 1 0 obj
 <<
-/CreationDate (D:20091006130908)
-/ModDate (D:20091006130908)
+/CreationDate (D:20091006135110)
+/ModDate (D:20091006135110)
 /Title (R Graphics Output)
 /Producer (R 2.10.0)
 /Creator (R)
@@ -282,7 +282,7 @@
 65.85 76.68 l
 65.96 77.03 l
 66.06 77.39 l
-66.16 77.75 l
+66.16 77.76 l
 66.26 78.13 l
 66.36 78.51 l
 66.46 78.90 l
@@ -375,14 +375,14 @@
 75.26 162.23 l
 75.36 163.91 l
 75.46 165.60 l
-75.56 167.31 l
+75.56 167.30 l
 75.66 169.03 l
 75.76 170.77 l
 75.86 172.53 l
 75.96 174.31 l
 76.06 176.11 l
 76.17 177.92 l
-76.27 179.75 l
+76.27 179.74 l
 76.37 181.59 l
 76.47 183.45 l
 76.57 185.33 l
@@ -390,7 +390,7 @@
 76.77 189.14 l
 76.87 191.06 l
 76.97 193.01 l
-77.08 194.97 l
+77.08 194.96 l
 77.18 196.94 l
 77.28 198.93 l
 77.38 200.93 l
@@ -407,7 +407,7 @@
 78.49 223.93 l
 78.59 226.10 l
 78.69 228.28 l
-78.79 230.47 l
+78.79 230.48 l
 78.90 232.68 l
 79.00 234.90 l
 79.10 237.12 l
@@ -424,14 +424,14 @@
 80.21 262.24 l
 80.31 264.57 l
 80.41 266.90 l
-80.51 269.24 l
+80.51 269.25 l
 80.61 271.59 l
 80.72 273.94 l
 80.82 276.30 l
 80.92 278.66 l
 81.02 281.02 l
 81.12 283.39 l
-81.22 285.76 l
+81.22 285.75 l
 81.32 288.13 l
 81.42 290.50 l
 81.52 292.87 l
@@ -446,9 +446,9 @@
 82.43 314.20 l
 82.54 316.56 l
 82.64 318.92 l
-82.74 321.27 l
+82.74 321.26 l
 82.84 323.61 l
-82.94 325.94 l
+82.94 325.95 l
 83.04 328.28 l
 83.14 330.60 l
 83.24 332.92 l
@@ -459,21 +459,21 @@
 83.75 344.37 l
 83.85 346.63 l
 83.95 348.88 l
-84.05 351.12 l
+84.05 351.11 l
 84.15 353.34 l
 84.25 355.55 l
 84.35 357.75 l
 84.46 359.93 l
 84.56 362.10 l
 84.66 364.26 l
-84.76 366.40 l
+84.76 366.39 l
 84.86 368.52 l
 84.96 370.63 l
 85.06 372.71 l
 85.16 374.78 l
 85.26 376.84 l
 85.37 378.87 l
-85.47 380.89 l
+85.47 380.88 l
 85.57 382.88 l
 85.67 384.85 l
 85.77 386.81 l
@@ -485,7 +485,7 @@
 86.38 398.05 l
 86.48 399.85 l
 86.58 401.61 l
-86.68 403.35 l
+86.68 403.36 l
 86.78 405.07 l
 86.88 406.76 l
 86.98 408.42 l
@@ -493,7 +493,7 @@
 87.19 411.66 l
 87.29 413.24 l
 87.39 414.79 l
-87.49 416.32 l
+87.49 416.31 l
 87.59 417.81 l
 87.69 419.27 l
 87.79 420.70 l
@@ -579,7 +579,7 @@
 95.88 419.32 l
 95.98 417.88 l
 96.08 416.41 l
-96.18 414.92 l
+96.18 414.91 l
 96.28 413.39 l
 96.39 411.84 l
 96.49 410.26 l
@@ -606,9 +606,9 @@
 98.61 371.75 l
 98.71 369.70 l
 98.81 367.63 l
-98.91 365.56 l
+98.91 365.55 l
 99.01 363.46 l
-99.11 361.35 l
+99.11 361.36 l
 99.22 359.24 l
 99.32 357.10 l
 99.42 354.96 l
@@ -623,7 +623,7 @@
 100.33 335.17 l
 100.43 332.93 l
 100.53 330.68 l
-100.63 328.42 l
+100.63 328.43 l
 100.73 326.16 l
 100.83 323.90 l
 100.93 321.63 l
@@ -631,12 +631,12 @@
 101.14 317.07 l
 101.24 314.79 l
 101.34 312.50 l
-101.44 310.22 l
-101.54 307.93 l
+101.44 310.21 l
+101.54 307.92 l
 101.64 305.63 l
 101.74 303.34 l
 101.84 301.05 l
-101.95 298.76 l
+101.95 298.75 l
 102.05 296.46 l
 102.15 294.17 l
 102.25 291.88 l
@@ -650,41 +650,41 @@
 103.06 273.64 l
 103.16 271.38 l
 103.26 269.12 l
-103.36 266.88 l
+103.36 266.87 l
 103.46 264.63 l
 103.56 262.39 l
 103.66 260.16 l
 103.77 257.93 l
 103.87 255.72 l
 103.97 253.51 l
-104.07 251.30 l
+104.07 251.31 l
 104.17 249.11 l
 104.27 246.93 l
 104.37 244.75 l
-104.47 242.58 l
+104.47 242.59 l
 104.57 240.43 l
 104.68 238.28 l
-104.78 236.14 l
+104.78 236.15 l
 104.88 234.02 l
 104.98 231.90 l
 105.08 229.80 l
 105.18 227.71 l
 105.28 225.63 l
-105.38 223.55 l
+105.38 223.56 l
 105.48 221.50 l
 105.59 219.45 l
 105.69 217.42 l
 105.79 215.40 l
 105.89 213.39 l
 105.99 211.40 l
-106.09 209.41 l
+106.09 209.42 l
 106.19 207.45 l
 106.29 205.49 l
 106.39 203.55 l
 106.49 201.63 l
 106.60 199.72 l
 106.70 197.82 l
-106.80 195.93 l
+106.80 195.94 l
 106.90 194.07 l
 107.00 192.21 l
 107.10 190.37 l
@@ -696,11 +696,11 @@
 107.71 179.66 l
 107.81 177.93 l
 107.91 176.21 l
-108.01 174.52 l
+108.01 174.51 l
 108.11 172.83 l
 108.21 171.16 l
 108.31 169.51 l
-108.42 167.88 l
+108.42 167.87 l
 108.52 166.26 l
 108.62 164.65 l
 108.72 163.07 l
@@ -724,8 +724,8 @@
 110.54 137.28 l
 110.64 136.00 l
 110.74 134.74 l
-110.84 133.50 l
-110.94 132.27 l
+110.84 133.49 l
+110.94 132.26 l
 111.04 131.05 l
 111.15 129.85 l
 111.25 128.67 l
@@ -734,7 +734,7 @@
 111.55 125.21 l
 111.65 124.09 l
 111.75 122.99 l
-111.85 121.90 l
+111.85 121.89 l
 111.95 120.82 l
 112.06 119.76 l
 112.16 118.71 l
@@ -756,7 +756,7 @@
 113.77 103.94 l
 113.87 103.13 l
 113.98 102.34 l
-114.08 101.56 l
+114.08 101.55 l
 114.18 100.79 l
 114.28 100.03 l
 114.38 99.29 l
@@ -861,7 +861,7 @@
 124.39 66.88 l
 124.49 66.80 l
 124.59 66.72 l
-124.69 66.64 l
+124.69 66.63 l
 124.79 66.56 l
 124.89 66.48 l
 125.00 66.40 l

Modified: branches/distr-2.2/pkg/distr/man/internals-qqplot.Rd
===================================================================
--- branches/distr-2.2/pkg/distr/man/internals-qqplot.Rd	2009-10-06 11:11:49 UTC (rev 599)
+++ branches/distr-2.2/pkg/distr/man/internals-qqplot.Rd	2009-10-06 11:52:29 UTC (rev 600)
@@ -36,7 +36,10 @@
 .confqq(x,D, withConf.pw  = TRUE,  withConf.sim = TRUE, alpha,
                     col.pCI, lty.pCI, lwd.pCI, pch.pCI, cex.pCI,
                     col.sCI, lty.sCI, lwd.sCI, pch.sCI, cex.sCI,
-                    n,exact.sCI=(n<100),exact.pCI=(n<100), nosym.pCI = FALSE)
+                    n,exact.sCI=(n<100),exact.pCI=(n<100),
+                    nosym.pCI = FALSE, with.legend = TRUE,
+                    legend.bg = "white", legend.pos = "topleft",
+                    legend.cex = 0.8)
 
 .deleteItemsMCL(mcl)
 .distrExInstalled
@@ -80,6 +83,10 @@
 \item{lwd.sCI}{line width for the simultaneous CI}
 \item{pch.sCI}{symbol for points (for discrete mass points) in simultaneous CI}
 \item{cex.sCI}{magnification factor for points (for discrete mass points) in simultaneous CI}
+\item{with.legend}{logical; shall a legend be plotted?}
+\item{legend.bg}{background color for the legend}
+\item{legend.pos}{position for the legend}
+\item{legend.cex}{magnification factor for the legend}
 \item{mcl}{arguments in call as a list}
 }
 

Modified: branches/distr-2.2/pkg/distr/man/qqplot.Rd
===================================================================
--- branches/distr-2.2/pkg/distr/man/qqplot.Rd	2009-10-06 11:11:49 UTC (rev 599)
+++ branches/distr-2.2/pkg/distr/man/qqplot.Rd	2009-10-06 11:52:29 UTC (rev 600)
@@ -22,7 +22,8 @@
     cex.sCI = par("cex"),
     cex.pch = par("cex"), col.pch = par("col"),
     jit.fac = 0, check.NotInSupport = TRUE,
-    col.NotInSupport = "red")
+    col.NotInSupport = "red", with.legend = TRUE, legend.bg = "white",
+    legend.pos = "topleft", legend.cex = 0.8)
 \S4method{qqplot}{ANY,ANY}(x, y,
     plot.it = TRUE, xlab = deparse(substitute(x)),
     ylab = deparse(substitute(y)), ...)
@@ -70,6 +71,10 @@
 \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)}?}
 \item{col.NotInSupport}{logical; if preceding check \code{TRUE} color of \code{x}-quantiles if not in \code{support(y)}}
+\item{with.legend}{logical; shall a legend be plotted?}
+\item{legend.bg}{background color for the legend}
+\item{legend.pos}{position for the legend}
+\item{legend.cex}{magnification factor for the legend}
 }
 
 \description{

Modified: branches/distr-2.2/pkg/distrMod/R/qqplot.R
===================================================================
--- branches/distr-2.2/pkg/distrMod/R/qqplot.R	2009-10-06 11:11:49 UTC (rev 599)
+++ branches/distr-2.2/pkg/distrMod/R/qqplot.R	2009-10-06 11:52:29 UTC (rev 600)
@@ -87,7 +87,11 @@
              adj.lbl = NULL,      ## adj parameter for the plotted observation labels
              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)
+             col.NotInSupport = "red", ## if preceding check TRUE color of x if not in support(y)
+             with.legend = TRUE,  ## shall a legend be plotted
+             legend.bg = "white", ## background for the legend
+             legend.pos = "topleft", ## position for the legend
+             legend.cex = 0.8     ## magnification factor for the legend
     ){ ## return value as in stats::qqplot
 
     mc <- match.call(call = sys.call(sys.parent(1)))
@@ -192,7 +196,9 @@
                       col.pCI, lty.pCI, lwd.pCI, pch.pCI, cex.pCI,
                       col.sCI, lty.sCI, lwd.sCI, pch.sCI, cex.sCI,
                   n, exact.sCI = exact.sCI, exact.pCI = exact.pCI,
-                  nosym.pCI = nosym.pCI)
+                  nosym.pCI = nosym.pCI, with.legend = with.legend,
+                  legend.bg = legend.bg, legend.pos = legend.pos,
+                  legend.cex = legend.cex)
        }
     }
     return(ret)

Modified: branches/distr-2.2/pkg/distrMod/man/qqplot.Rd
===================================================================
--- branches/distr-2.2/pkg/distrMod/man/qqplot.Rd	2009-10-06 11:11:49 UTC (rev 599)
+++ branches/distr-2.2/pkg/distrMod/man/qqplot.Rd	2009-10-06 11:52:29 UTC (rev 600)
@@ -18,7 +18,9 @@
     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")
+    jit.fac = 0, check.NotInSupport = TRUE, col.NotInSupport = "red",
+    with.legend = TRUE, legend.bg = "white",
+    legend.pos = "topleft", legend.cex = 0.8)
 \S4method{qqplot}{ANY,ProbFamily}(x, y,
    n = length(x), withIdLine = TRUE, withConf = TRUE,
    withConf.pw  = withConf,  withConf.sim = withConf,
@@ -89,6 +91,10 @@
 in \code{support(y)}?}
 \item{col.NotInSupport}{logical; if preceding check \code{TRUE} color of
 \code{x}-quantiles if not in \code{support(y)}}
+\item{with.legend}{logical; shall a legend be plotted?}
+\item{legend.bg}{background color for the legend}
+\item{legend.pos}{position for the legend}
+\item{legend.cex}{magnification factor for the legend}
 }
 \description{
   We generalize function \code{\link[stats:qqnorm]{qqplot}} from package \pkg{stats} to



More information about the Distr-commits mailing list