[Dplr-commits] r748 - in pkg/dplR: . R man

noreply at r-forge.r-project.org noreply at r-forge.r-project.org
Sun Mar 30 00:31:49 CET 2014


Author: andybunn
Date: 2014-03-30 00:31:48 +0100 (Sun, 30 Mar 2014)
New Revision: 748

Added:
   pkg/dplR/R/plot.rwl.R
   pkg/dplR/man/plot.rwl.Rd
Modified:
   pkg/dplR/ChangeLog
   pkg/dplR/NAMESPACE
   pkg/dplR/R/seg.plot.R
   pkg/dplR/R/spag.plot.R
Log:
The main thing in this commit is the new wrapper to plot rwl objects. This is setting the stage for having plot, summary, etc. methods for rwl objects. There are still several things to work on. Like setting the class() of rwl data objects via read.rwl (and in the onboard data sets). And will this class change break any existing functions?

Modified: pkg/dplR/ChangeLog
===================================================================
--- pkg/dplR/ChangeLog	2014-03-29 03:21:54 UTC (rev 747)
+++ pkg/dplR/ChangeLog	2014-03-29 23:31:48 UTC (rev 748)
@@ -3,7 +3,21 @@
 File: NAMESPACE
 -------------------------
 - Added chron.plot to export list.
+- Added rwl.plot as an S3Method.
 
+File: rwl.plot.R
+-------------------------
+- New wrapper to plot rwl objects. This is setting the
+  stage for having plot, summary, etc. methods for rwl
+  objects. There are still several things to work on. Like
+  setting the class() of rwl data objects via read.rwl (and in 
+  the onboard data sets). And will this class change break any 
+  existing functions?
+
+File: spag.plot.R
+-------------------------
+- Cosmetic changes to plot.
+
 File: seg.plot.R
 -------------------------
 - Cosmetic changes to plot.

Modified: pkg/dplR/NAMESPACE
===================================================================
--- pkg/dplR/NAMESPACE	2014-03-29 03:21:54 UTC (rev 747)
+++ pkg/dplR/NAMESPACE	2014-03-29 23:31:48 UTC (rev 748)
@@ -36,6 +36,7 @@
        series.rwl.plot, skel.plot, spag.plot, strip.rwl, tbrm,
        tridas.vocabulary, uuid.gen, wavelet.plot, wc.to.po,
        write.compact, write.crn, write.rwl, write.tridas,
-       write.tucson, chron.plot)
+       write.tucson, chron.plot, plot.rwl)
 
 S3method(print, redfit)
+S3method(plot, rwl)

Added: pkg/dplR/R/plot.rwl.R
===================================================================
--- pkg/dplR/R/plot.rwl.R	                        (rev 0)
+++ pkg/dplR/R/plot.rwl.R	2014-03-29 23:31:48 UTC (rev 748)
@@ -0,0 +1,5 @@
+plot.rwl <- function(rwl,type=c("seg","spag"),...){
+  switch(match.arg(type),
+         seg = seg.plot(rwl,...),
+         spag = spag.plot(rwl,...))
+}

Modified: pkg/dplR/R/seg.plot.R
===================================================================
--- pkg/dplR/R/seg.plot.R	2014-03-29 03:21:54 UTC (rev 747)
+++ pkg/dplR/R/seg.plot.R	2014-03-29 23:31:48 UTC (rev 748)
@@ -15,8 +15,8 @@
     }
     segs.axis2 <- names(segs)
     segs.axis4 <- names(segs)
-    segs.axis2[seq(1,n.col,by=2)] <- NA
-    segs.axis4[seq(2,n.col,by=2)] <- NA
+    segs.axis2[seq(2,n.col,by=2)] <- NA
+    segs.axis4[seq(1,n.col,by=2)] <- NA
     op <- par(no.readonly=TRUE) # Save par
     on.exit(par(op))            # Reset par on exit
     par(mar=c(2, 5, 2, 5) + 0.1, mgp=c(1.1, 0.1, 0), tcl=0.5,
@@ -24,6 +24,7 @@
     plot(yr, segs[[1]], type="n", ylim=c(0, n.col), axes=FALSE,
          ylab="", xlab=gettext("Year", domain="R-dplR"), ...)
     abline(h=seq.col,lwd=1,col="grey")
+    grid(ny = NA)
     apply(segs, 2, lines, x=yr, lwd=4,lend=2)
     axis(2, at=seq.col, labels=segs.axis2, srt=45, tick=FALSE, las=2)
     axis(4, at=seq.col, labels=segs.axis4, srt=45, tick=FALSE, las=2)

Modified: pkg/dplR/R/spag.plot.R
===================================================================
--- pkg/dplR/R/spag.plot.R	2014-03-29 03:21:54 UTC (rev 747)
+++ pkg/dplR/R/spag.plot.R	2014-03-29 23:31:48 UTC (rev 748)
@@ -10,7 +10,8 @@
     rwl2 <- rwl2[, neworder, drop=FALSE]
     op <- par(no.readonly=TRUE)
     on.exit(par(op))
-    par(mar=c(4, 4, 4, 4) + 0.1, mgp=c(1.25, 0.25, 0), tcl=0.25)
+    par(mar=c(2, 5, 2, 5) + 0.1, mgp=c(1.1, 0.1, 0), tcl=0.5,
+        xaxs="i")
     ## Set vertical offset for plotting each series
     for (i in 1:nseries) {
         rwl2[, i] <- rwl2[, i] + i

Added: pkg/dplR/man/plot.rwl.Rd
===================================================================
--- pkg/dplR/man/plot.rwl.Rd	                        (rev 0)
+++ pkg/dplR/man/plot.rwl.Rd	2014-03-29 23:31:48 UTC (rev 748)
@@ -0,0 +1,40 @@
+\name{plot.rwl}
+\alias{plot.rwl}
+\title{
+  Plotting rwl objects
+}
+\description{
+  Plots rwl objects
+}
+\usage{
+\method{plot}{rwl}(rwl, type=c("seg","spag"), ...)
+}
+\arguments{
+
+  \item{rwl}{ An object of class \code{"rwl"}.  }
+
+  \item{type}{ Character. Type "seg" calls \code{\link{seg.plot}} 
+  while "spag" calls \code{\link{spag.plot}} }
+
+  \item{\dots}{ Additional arguemnts for each \code{type}  }
+  
+}
+\value{
+  None. A plot is produced.
+}
+\author{
+  Andy Bunn
+}
+\seealso{
+  \code{\link{rwl}}
+}
+\examples{data(ca533)
+class(ca533) <- c(class(ca533),'rwl')
+plot.rwl(ca533,type=c('seg'))
+plot.rwl(ca533,type=c('spag'))
+plot.rwl(ca533,type=c('spag'),zfac=2)
+## to use as S3Method the class of rwl must be set:
+class(ca533) <- c('rwl','data.frame')
+plot(ca533,type=c('seg'))
+}
+\keyword{ plot }



More information about the Dplr-commits mailing list