[Distr-commits] r384 - in branches/distr-2.1/pkg: distr/R distr/chm distr/man distrMod/R distrMod/chm distrMod/man

noreply at r-forge.r-project.org noreply at r-forge.r-project.org
Wed Jan 28 04:38:25 CET 2009


Author: ruckdeschel
Date: 2009-01-28 04:38:25 +0100 (Wed, 28 Jan 2009)
New Revision: 384

Modified:
   branches/distr-2.1/pkg/distr/R/plot-methods.R
   branches/distr-2.1/pkg/distr/R/plot-methods_LebDec.R
   branches/distr-2.1/pkg/distr/chm/Distr.chm
   branches/distr-2.1/pkg/distr/chm/plot-methods.html
   branches/distr-2.1/pkg/distr/man/plot-methods.Rd
   branches/distr-2.1/pkg/distrMod/R/AllPlot.R
   branches/distr-2.1/pkg/distrMod/chm/L2ParamFamily-class.html
   branches/distr-2.1/pkg/distrMod/chm/distrMod.chm
   branches/distr-2.1/pkg/distrMod/man/L2ParamFamily-class.Rd
Log:
fixed xlim and ylim args for plots;
ylim can now be matrix-valued...

Modified: branches/distr-2.1/pkg/distr/R/plot-methods.R
===================================================================
--- branches/distr-2.1/pkg/distr/R/plot-methods.R	2009-01-27 23:38:09 UTC (rev 383)
+++ branches/distr-2.1/pkg/distr/R/plot-methods.R	2009-01-28 03:38:25 UTC (rev 384)
@@ -164,9 +164,11 @@
      
      
      if(hasArg(ylim))
-         {if(length(ylim)!=2) 
+         {if(! length(ylim) %in% c(2,4)) 
              stop("Wrong length of Argument ylim"); 
-           ylim1 <- ylim; ylim2 <- ylim;
+           if(length(ylim)==2)
+             ylim <- matrix(ylim, 2,2)
+           ylim1 <- ylim[,1]; ylim2 <- ylim[,2];
            }
      else {ylim1 <- c(0,max(dxg[dxg<50])); ylim2 <- c(-0.05,1.05)}
 
@@ -240,7 +242,7 @@
      if(3%in%to.draw){
         options(warn = -1)
         do.call(plot, c(list(x = po, xo, type = "n", 
-             xlim = ylim, ylim = xlim, ylab = "q(p)", xlab = "p", 
+             xlim = ylim2, ylim = xlim, ylab = "q(p)", xlab = "p", 
              log = logq), dots.without.pch))
         options(warn = o.warn)
     

Modified: branches/distr-2.1/pkg/distr/R/plot-methods_LebDec.R
===================================================================
--- branches/distr-2.1/pkg/distr/R/plot-methods_LebDec.R	2009-01-27 23:38:09 UTC (rev 383)
+++ branches/distr-2.1/pkg/distr/R/plot-methods_LebDec.R	2009-01-28 03:38:25 UTC (rev 384)
@@ -260,18 +260,22 @@
      pxg <- p(x)(grid)
 
 
+     
      if(hasArg(ylim))
-         {if(length(ylim)!=2)
-             stop("Wrong length of Argument ylim")}
+         {if(! length(ylim) %in% c(2,4)) 
+             stop("Wrong length of Argument ylim"); 
+           if(length(ylim)==2)
+             ylim <- matrix(ylim, 2,2)
+           ylim2 <- ylim[,2];
+           }
+     else ylim2 <- c(-0.05,1.05)
 
-     else {ylim <- c(-0.05,1.05)}
-
      if(hasArg(log))
          {logpd <- dots$log
           logq <- gsub("u","y",gsub("y","x",gsub("x", "u", logpd)))
           if(length(grep("y",logpd))){
-             ylim <- c(max(min(pxg[pxg>0]), ylim[1]),
-                               ylim[2])
+             ylim2 <- c(max(min(pxg[pxg>0]), ylim2[1]),
+                               ylim2[2])
              }
           }
 
@@ -288,7 +292,7 @@
      if(1 %in% to.draw){
         on.exit(options(warn=o.warn))
         do.call(plot, c(list(x = grid, pxg, type = "l",
-             ylim = ylim, ylab = "p(q)", xlab = "q", log = logpd),
+             ylim = ylim2, ylab = "p(q)", xlab = "q", log = logpd),
              dots.without.pch))
         options(warn = o.warn)
    
@@ -346,7 +350,7 @@
      if(2 %in% to.draw){
         options(warn = -1)
         do.call(plot, c(list(x = po, xo, type = "n",
-             xlim = ylim, ylim = xlim, ylab = "q(p)", xlab = "p",
+             xlim = ylim2, ylim = xlim, ylab = "q(p)", xlab = "p",
              log = logq), dots.without.pch), envir = parent.frame(2))
         options(warn = o.warn)
    

Modified: branches/distr-2.1/pkg/distr/chm/Distr.chm
===================================================================
(Binary files differ)

Modified: branches/distr-2.1/pkg/distr/chm/plot-methods.html
===================================================================
--- branches/distr-2.1/pkg/distr/chm/plot-methods.html	2009-01-27 23:38:09 UTC (rev 383)
+++ branches/distr-2.1/pkg/distr/chm/plot-methods.html	2009-01-28 03:38:25 UTC (rev 384)
@@ -99,7 +99,11 @@
 allowed and leads to a "reversed axis". As in <code>plot.default</code>.</td></tr>
 <tr valign="top"><td><code>ylim</code></td>
 <td>
-the y limits of the plot. As in <code>plot.default</code>.</td></tr>
+the y limits of the plot. Either as in <code>plot.default</code>
+(i.e. a vector of length 2) or a vector of length 4, where the first two
+elements are the values for <code>ylim</code> in panel "d", and the last
+two elements are the values for <code>ylim</code> resp. <code>xlim</code> in panels "p",
+and "q".</td></tr>
 <tr valign="top"><td><code>width</code></td>
 <td>
 width (in inches) of the graphics device opened</td></tr>

Modified: branches/distr-2.1/pkg/distr/man/plot-methods.Rd
===================================================================
--- branches/distr-2.1/pkg/distr/man/plot-methods.Rd	2009-01-27 23:38:09 UTC (rev 383)
+++ branches/distr-2.1/pkg/distr/man/plot-methods.Rd	2009-01-28 03:38:25 UTC (rev 384)
@@ -60,7 +60,11 @@
   \item{y}{ missing }
   \item{xlim}{the x limits (x1, x2) of the plot.  Note that \code{x1 > x2} is
               allowed and leads to a "reversed axis". As in \code{plot.default}.}
-  \item{ylim}{the y limits of the plot. As in \code{plot.default}.}
+  \item{ylim}{the y limits of the plot. Either as in \code{plot.default}
+  (i.e. a vector of length 2) or a vector of length 4, where the first two
+   elements are the values for \code{ylim} in panel "d", and the last
+   two elements are the values for \code{ylim} resp. \code{xlim} in panels "p",
+   and "q".}
   \item{width}{width (in inches) of the graphics device opened}
   \item{height}{height (in inches) of the graphics device opened}
   \item{withSweave}{logical: if \code{TRUE} (for working with \command{Sweave}) 

Modified: branches/distr-2.1/pkg/distrMod/R/AllPlot.R
===================================================================
--- branches/distr-2.1/pkg/distrMod/R/AllPlot.R	2009-01-27 23:38:09 UTC (rev 383)
+++ branches/distr-2.1/pkg/distrMod/R/AllPlot.R	2009-01-28 03:38:25 UTC (rev 384)
@@ -57,25 +57,48 @@
         if(!is(e1, "UnivariateDistribution")) stop("not yet implemented")
 
 
-        if(is(e1, "AbscontDistribution")){
-            lower <- ifelse(is.finite(q(e1)(0)), q(e1)(0), q(e1)(getdistrOption("TruncQuantile")))
-            upper <- ifelse(is.finite(q(e1)(1)), q(e1)(1), q(e1)(1 - getdistrOption("TruncQuantile")))
-            h <- upper - lower
-            x.vec <- seq(from = lower - 0.1*h, to = upper + 0.1*h, length = 1000)
-            plty <- "l"
-            lty <- "solid"
-        }else{
-            if(is(e1, "DiscreteDistribution")){
-                x.vec <- support(e1)
-                plty <- "p"
-                lty <- "dotted"
+        if(is(e1, "UnivariateDistribution")){
+           xlim <- eval(dots$xlim)
+           if(!is.null(xlim)){ 
+               xm <- min(xlim)
+               xM <- max(xlim)
+            }
+            if(is(e1, "AbscontDistribution")){
+                lower <- if(is.finite(q(e1)(0))) 
+                     q(e1)(0) else q(e1)(getdistrOption("TruncQuantile"))
+                upper <- if(is.finite(q(e1)(1))) 
+                     q(e1)(1) else q(e1)(1 - getdistrOption("TruncQuantile"))
+                if(!is.null(xlim)){ 
+                  lower <- min(lower,xm)
+                  upper <- max(upper,xM)
+                }
+                h <- upper - lower
+                x.vec <- seq(from = lower - 0.1*h, to = upper + 0.1*h, length = 1000)
+                plty <- "l"
+                lty <- "solid"
             }else{
-                x.vec <- r(e1)(1000)
-                x.vec <- sort(unique(x.vec))
+                if(is(e1, "DiscreteDistribution")) x.vec <- support(e1)
+                else{
+                   x.vec <- r(e1)(1000)
+                   x.vec <- sort(unique(x.vec))
+                }
                 plty <- "p"
                 lty <- "dotted"
+                if(!is.null(xlim)) x.vec <- x.vec[(x.vec>=xm) & (x.vec<=xM)]
             }
         }
+        dxg <- d(e1)(x.vec)
+        pxg <- p(e1)(x.vec)
+        ylim <- eval(dots$ylim)
+        if(!is.null(ylim)){ 
+               d.0 <- 1 %in% to.draw
+               d.1 <- 2 %in% to.draw | 3 %in% to.draw
+               if(! length(ylim) %in% c(2,2*(d.0+d.1+dims0))) 
+                  stop("Wrong length of Argument ylim"); 
+               ylim <- matrix(ylim, 2,d.0+d.1+dims0)
+               iy <- if(d.0+d.1==2) 1:2 else 1
+               dots$ylim <- ylim[,iy]
+        }
 
         
         L2deriv <- as(diag(dimm) %*% x at L2deriv, "EuclRandVariable")
@@ -189,9 +212,11 @@
         omar <- par("mar")
         parArgs <- c(parArgs,list(mar = c(bmar,omar[2],tmar,omar[4])))
        
-     do.call(par,args=parArgs)
+        dots$ylim <- NULL
+        do.call(par,args=parArgs)
         for(i in 1:dims0){
             indi <- l2dpl[i]-3
+            if(!is.null(ylim)) dots$ylim <- ylim[,d.0+d.1+i]       
             do.call(plot, args=c(list(x=x.vec, y=sapply(x.vec, L2deriv at Map[[indi]]),
                                  type = plty, lty = lty,
                                  xlab = "x",

Modified: branches/distr-2.1/pkg/distrMod/chm/L2ParamFamily-class.html
===================================================================
--- branches/distr-2.1/pkg/distrMod/chm/L2ParamFamily-class.html	2009-01-27 23:38:09 UTC (rev 383)
+++ branches/distr-2.1/pkg/distrMod/chm/L2ParamFamily-class.html	2009-01-28 03:38:25 UTC (rev 384)
@@ -225,6 +225,12 @@
 
 <p>
 </ul> 
+if <code>...</code> contains argument <code>ylim</code>, this may either be
+as in <code>plot.default</code> (i.e. a vector of length 2) or a vector of 
+length 4, where the first two elements are the values for <code>ylim</code> 
+in panels "d.c" and "d.d", and the last
+two elements are the values for <code>ylim</code> resp. <code>xlim</code> in panels 
+"p", "p.c", "p.d" and "q", "q.c", "q.d".
 </dd>
 
 

Modified: branches/distr-2.1/pkg/distrMod/chm/distrMod.chm
===================================================================
(Binary files differ)

Modified: branches/distr-2.1/pkg/distrMod/man/L2ParamFamily-class.Rd
===================================================================
--- branches/distr-2.1/pkg/distrMod/man/L2ParamFamily-class.Rd	2009-01-27 23:38:09 UTC (rev 383)
+++ branches/distr-2.1/pkg/distrMod/man/L2ParamFamily-class.Rd	2009-01-28 03:38:25 UTC (rev 384)
@@ -195,8 +195,15 @@
                \code{\link[stats]{plot.stepfun}} }
 
       } 
-      }
+      if \code{\dots} contains argument \code{ylim}, this may either be
+      as in \code{plot.default} (i.e. a vector of length 2) or a vector of 
+      length 4, where the first two elements are the values for \code{ylim} 
+      in panels "d.c" and "d.d", and the last
+      two elements are the values for \code{ylim} resp. \code{xlim} in panels 
+      "p", "p.c", "p.d" and "q", "q.c", "q.d".
+    }
 
+
     \item{modifyModel}{\code{signature(model = "L2ParamFamily", param = "ParamFamParameter")}:
       moves the L2-parametric Family \code{model} to parameter \code{param} }
   }



More information about the Distr-commits mailing list