[Stpp-commits] r11 - in pkg: R man
noreply at r-forge.r-project.org
noreply at r-forge.r-project.org
Tue Oct 28 13:07:29 CET 2008
Author: gabriele
Date: 2008-10-28 13:07:28 +0100 (Tue, 28 Oct 2008)
New Revision: 11
Modified:
pkg/R/animation.r
pkg/man/animation.Rd
Log:
Modified: pkg/R/animation.r
===================================================================
--- pkg/R/animation.r 2008-10-28 11:57:29 UTC (rev 10)
+++ pkg/R/animation.r 2008-10-28 12:07:28 UTC (rev 11)
@@ -1,71 +1,73 @@
-animation <- function(xyt, s.region, t.region, runtime=1, incident="red", prevalent="pink3", fade=0.01, pch=19, cex=0.25, plot.s.region=T, scales=T, border.frac=0.05, add=F)
-{
- #
- # Description:
- # Animation of spatio-temporal point process data.
- # Requires splancs library
- #
- # Arguments:
- # xyt: data - matrix containing the (x,y,t)-coordinates
- # runtime: approximate running time of animation, in seconds
- # s.region: two-column matrix specifying polygonal
- # region containing all data-locations xyt[,1:2]
- # t.region: interval containing all data-times xyt[,3]
- # incident: colour in which incident point xyt[i,1:2] is
- # plotted at time xyt[i,3]
- # prevalent: colour to which prevalent point xyt[1,1:2] fades
- # at time xyt[i,3]+fade
- # fade: approximate time-delay for colour-change from incident
- # to prevalent, in data-time units
- # pch: plotting symbol usedfor each point
- # cex: magnification of plotting symbol relative to standard size
- # plot.s.region: if true, plot s.region as polygon
- # scales: if true, plot X and Y axes with scales
- # border.frac: extent of border of plotting region surounding s.region,
- # as fraction of ranges of X and Y
- #
- #
-
-
- if (missing(s.region)) s.region <- sbox(xyt[,1:2],xfrac=0.01,yfrac=0.01)
- if (missing(t.region)) t.region <- range(xyt[,3],na.rm=T)
-
-# par(pty="s",mfrow=c(1,1))
- ott<-order(xyt[,3])
- sxyt<-xyt[ott,]
- rangex<-range(s.region[,1])
- rangey<-range(s.region[,2])
- xlim<-c(rangex[1]-border.frac*(rangex[2]-rangex[1]),rangex[2]+border.frac*(rangex[2]-rangex[1]))
- ylim<-c(rangey[1]-border.frac*(rangey[2]-rangey[1]),rangey[2]+border.frac*(rangey[2]-rangey[1]))
- xy<-as.matrix(sxyt[,1:2])
- tt<-sxyt[,3]
- npts<-length(tt)
- T0 <- max(t.region)
-
- if (add==F)
- {
- if (scales==F)
- plot(xy[,1],xy[,2],type="n",xlim=xlim,ylim=ylim,xaxt="n",yaxt="n",bty="n",xlab=" ",ylab=" ")
- if (scales==T)
- plot(sxyt[,1],sxyt[,2],type="n",xlim=xlim,ylim=ylim,bty="n",xlab="X",ylab="Y")
- if (plot.s.region==T)
- polymap(as.points(s.region),add=T,lwd=2)
- }
- nplotted<-0
- tt.now<-0
- tt.fade<-0
- while (nplotted<npts)
- {
- i<-nplotted+1
- tt.gap<-tt[i]-tt.now
- junk<-Sys.sleep((tt.gap/T0)*runtime)
- n.fade<-sum(tt[1:i]<tt.fade)
- if (sum(n.fade)>0)
- points(xy[1:n.fade,1],xy[1:n.fade,2],col=prevalent,pch=19,cex=cex)
- points(xy[i,1],xy[i,2],col=incident,pch=19,cex=cex)
- nplotted<-i
- tt.now<-tt[i]
- tt.fade<-tt.now-fade
- }
-}
-
+animation <- function(xyt, s.region, t.region, runtime=1, incident="red", prevalent="pink3", pch=19, cex=0.35, plot.s.region=T, scales=T, border.frac=0.05, add=F)
+{
+ #
+ # Description:
+ # Animation of spatio-temporal point process data.
+ # Requires splancs library
+ #
+ # Arguments:
+ # xyt: data - matrix containing the (x,y,t)-coordinates
+ # runtime: approximate running time of animation, in seconds
+ # (but longer than expected...).
+ # s.region: two-column matrix specifying polygonal
+ # region containing all data-locations xyt[,1:2]
+ # t.region: interval containing all data-times xyt[,3]
+ # incident: colour in which incident point xyt[i,1:2] is
+ # plotted at time xyt[i,3]
+ # prevalent: colour to which prevalent point xyt[i,1:2] fades
+ # at time xyt[i+1,3]
+ # pch: plotting symbol usedfor each point
+ # cex: magnification of plotting symbol relative to standard size
+ # plot.s.region: if true, plot s.region as polygon
+ # scales: if true, plot X and Y axes with scales
+ # border.frac: extent of border of plotting region surounding s.region,
+ # as fraction of ranges of X and Y
+ #
+ #
+
+
+ if (missing(s.region)) s.region <- sbox(xyt[,1:2],xfrac=0.01,yfrac=0.01)
+ if (missing(t.region)) t.region <- range(xyt[,3],na.rm=T)
+
+ ott<-order(xyt[,3])
+ sxyt<-xyt[ott,]
+ rangex<-range(s.region[,1])
+ rangey<-range(s.region[,2])
+ xlim<-c(rangex[1]-border.frac*(rangex[2]-rangex[1]),rangex[2]+border.frac*(rangex[2]-rangex[1]))
+ ylim<-c(rangey[1]-border.frac*(rangey[2]-rangey[1]),rangey[2]+border.frac*(rangey[2]-rangey[1]))
+ xy<-as.matrix(sxyt[,1:2])
+ tt<-sxyt[,3]
+ npts<-length(tt)
+ T0=length(unique(tt))
+
+ if (add==F)
+ {
+ if (scales==F)
+ plot(xy[,1],xy[,2],type="n",xlim=xlim,ylim=ylim,xaxt="n",yaxt="n",bty="n",xlab=" ",ylab=" ")
+ if (scales==T)
+ plot(sxyt[,1],sxyt[,2],type="n",xlim=xlim,ylim=ylim,bty="n",xlab="X",ylab="Y")
+ if (plot.s.region==T)
+ polymap(as.points(s.region),add=T,lwd=2)
+ }
+ nplotted<-0
+ tt.now<-0
+ tt.fade<-0
+ while (nplotted<npts)
+ {
+ i<-nplotted+1
+ tt.gap<-tt[i]-tt.now
+ if (!(is.null(runtime)))
+ junk<-Sys.sleep((tt.gap/T0)*runtime)
+ n.fade<-sum(tt[1:i]<=tt.fade)
+ if (sum(n.fade)>0)
+ points(xy[1:n.fade,1],xy[1:n.fade,2],col=prevalent,pch=19,cex=cex)
+
+ M=which(tt==tt[i])
+ points(xy[M,1],xy[M,2],col=incident,pch=19,cex=cex)
+ nplotted<-nplotted+length(M)
+ tt.now<-tt[i]
+ tt.fade<-tt.now
+ }
+}
+
+
Modified: pkg/man/animation.Rd
===================================================================
--- pkg/man/animation.Rd 2008-10-28 11:57:29 UTC (rev 10)
+++ pkg/man/animation.Rd 2008-10-28 12:07:28 UTC (rev 11)
@@ -10,28 +10,26 @@
}
\arguments{
- \item{xyt} data-matrix containing the (x,y,t)-coordinates.
- \item{s.region} two-column matrix specifying polygonal region containing
- all data-locations
- \code{xyt[,1:2]}.
- If missing, \code{s.region} is the bounding box of \code{xyt[,1:2]}.
- \item{t.region} interval containing all data-times \code{xyt[,3]}.
- If missing, \code{t.region} is defined by the range of \code{xyt[,3]}.
- \item{runtime} approximate running time of animation, in seconds,
- but it is longer than expected. May be \code{NULL}.
- \item{incident} colour in which incident point \code{xyt[i,1:2]} is
- plotted at time \code{xyt[i,3]}.
- \item{prevalent} colour to which prevalent point \code{xyt[i,1:2]} fades
- at time \code{xyt[i+1,3]}.
- \item{pch} plotting symbol used for each point.
- \item{cex} magnification of plotting symbol relative to standard size.
- \item{plot.s.region} if \code{TRUE}, plot \code{s.region} as polygon.
- \item{scales} if \code{TRUE}, plot X and Y axes with scales.
- \item{border.frac} extent of border of plotting region surounding
- \code{s.region}, as fraction of
- ranges of X and Y.
- \item{add} if \code{TRUE}, add the animation to an existing plot.
-\end{tabular}
+ \item{xyt}{data-matrix containing the (x,y,t)-coordinates. }
+ \item{s.region}{two-column matrix specifying polygonal region containing
+ all data-locations \code{xyt[,1:2]}.
+ If missing, \code{s.region} is the bounding box of \code{xyt[,1:2]}.}
+ \item{t.region}{interval containing all data-times \code{xyt[,3]}.
+ If missing, \code{t.region} is defined by the range of \code{xyt[,3]}.}
+ \item{runtime}{approximate running time of animation, in seconds,
+ but it is longer than expected. Can also be \code{NULL}.}
+ \item{incident}{colour in which incident point \code{xyt[i,1:2]} is
+ plotted at time \code{xyt[i,3]}.}
+ \item{prevalent}{colour to which prevalent point \code{xyt[i,1:2]} fades
+ at time \code{xyt[i+1,3]}.}
+ \item{pch}{plotting symbol used for each point.}
+ \item{cex}{magnification of plotting symbol relative to standard size.}
+ \item{plot.s.region}{if \code{TRUE}, plot \code{s.region} as polygon.}
+ \item{scales}{if \code{TRUE}, plot X and Y axes with scales.}
+ \item{border.frac}{extent of border of plotting region surounding
+ \code{s.region}, as fraction of ranges of X and Y.}
+ \item{add}{if \code{TRUE}, add the animation to an existing plot.}
+ }
\value{
None
More information about the Stpp-commits
mailing list