shape/0000755000176200001440000000000014051136043011347 5ustar liggesusersshape/NAMESPACE0000644000176200001440000000103513144517412012572 0ustar liggesusersimportFrom("grDevices", "col2rgb", "dev.new", "rgb") importFrom("graphics", "arrows", "lines", "mtext", "par", "plot", "polygon", "rect", "segments", "text") importFrom("stats", "approx") export(A4, Arrowhead, Arrows, colorlegend, cylindersegment, drapecol, emptyplot, femmecol, filledcircle, filledcylinder, filledellipse, filledmultigonal, filledrectangle, filledshape, getellipse, graycol, greycol, intpalette, plotcircle, plotellipse, rotatexy, roundrect, shadepalette, writelabel, textflag) shape/demo/0000755000176200001440000000000013162156472012305 5ustar liggesusersshape/demo/colorshapes.r0000644000176200001440000002527312005453757015024 0ustar liggesusers# Demo for shapes par(ask=TRUE) ##drapecol persp(volcano,theta = 135, phi = 30, col = drapecol(volcano),main="drapecol,femmecol") ##intpalette intpalette(c("white","black"),n=10) grey(seq(1,0,length.out=10)) image(matrix(nrow=1,ncol=100,data=1:100),main="intpalette", col=intpalette(c("red","blue"),numcol=100)) image(matrix(nrow=1,ncol=100,data=1:100),main="intpalette", col=intpalette(c("red","blue","yellow"),numcol=100)) image(matrix(nrow=1,ncol=100,data=1:100),main="intpalette", col=intpalette(c("red","blue","yellow","green"),numcol=100)) image(matrix(nrow=1,ncol=100,data=1:100),main="intpalette", col=intpalette(c("red","blue","yellow","green","black"),numcol=100)) ##shadepalette shadepalette(n=10,"white","black") image(matrix(nrow=1,ncol=100,data=1:100),col=shadepalette(100,"red","blue"), main="shadepalette") # rotatexy #---------------- xy <- matrix(ncol=2,data=c(1:5,rep(1,5))) plot(xy,xlim=c(-6,6),ylim=c(-6,6),type="b",pch=16,main="rotatexy",col=1) for ( i in 1:5) points(rotatexy(xy,mid=c(0,0),angle=60*i),col=i+1,type="b",pch=16) points(0,0,cex=2,pch=22,bg="black") legend("topright",legend=60*(0:5),col=1:6,pch=16,title="angle") legend("topleft",legend="midpoint",pt.bg="black",pt.cex=2,pch=22,box.lty=0) x <- seq(0,2*pi,pi/100) y <- sin(x) cols <- intpalette(c("blue","green","yellow","red"),n=250) cols <- c(cols,rev(cols)) plot(x,y,type="l",ylim=c(-3,3),main="rotatexy",col=cols[1],lwd=2,xlim=c(-1,7)) for (i in 2:500) lines(rotatexy(cbind(x,y),angle=0.36*i),col=cols[i],lwd=2) x <- seq(0,2*pi,pi/100) y <- sin(x*2) cols <- intpalette(c("red","yellow","black"),n=250) cols <- c(cols,rev(cols)) plot(x,y,type="l",ylim=c(-4,5),main="rotatexy, asp=TRUE",col=cols[1],lwd=2,xlim=c(-1,7)) for (i in 2:500) lines(rotatexy(cbind(x,y),angle=0.36*i,asp=TRUE),col=cols[i],lwd=2) cols <- femmecol(1000) plot(x,y,xlim=c(-1,1),ylim=c(-1,1),main="rotatexy",col=cols[1],type="n") for (i in 2:1000) {xy<-rotatexy(c(0,1),angle=0.36*i, mid=c(0,0)); points(xy[1],xy[2],col=cols[i],pch=".",cex=2)} # ellipses #---------------- emptyplot(c(-1.5,1.5)) cols <- rainbow(10) SS <- rev(seq(0.1,1,0.1)) plotellipse(rx=1.5,ry=0.6) plotellipse(rx=1.2,ry=0.4) for (i in 1:length(SS)) plotellipse(1,SS[i],col=cols[i],type="n") title("plotellipse") plotellipse(rx=1.5,ry=0.6,angle=0,from=pi,to=2*pi,arrow=TRUE,arr.pos=0.5) plotellipse(rx=1.2,ry=0.4,from=pi,to=2*pi) # emptyplot(c(-1.,1.)) col <- shadepalette(endcol="darkblue",n=100) filledellipse (rx1=1,ry1=0.8,col=col,lcol="black") plotellipse(rx=1,ry=0.35 ,angle=0,from=pi,to=2*pi,lwd=1,mid=c(0,0.)) plotellipse(rx=1.1,ry=0.6 ,angle=0,from=1.28*pi,to=1.72*pi,lwd=1,mid=c(0,-0.1)) plotellipse(rx=0.9 ,ry=0.32,angle=0,from=pi,to=2*pi,lwd=1,mid=c(0,0.35)) plotellipse(rx=0.65,ry=0.25,angle=0,from=pi,to=2*pi,lwd=1,mid=c(0,0.6)) plotellipse(rx=0.3 ,ry=0.1,angle=0,from=pi,to=2*pi,lwd=1,mid=c(0,0.75)) plotellipse(rx=0.8,ry=0.0,angle=90,from=pi,to=2*pi,lwd=1) plotellipse(rx=0.8,ry=0.35,angle=90,from=pi,to=2*pi,lwd=1) plotellipse(rx=0.8,ry=0.6,angle=90,from=pi,to=2*pi,lwd=1) plotellipse(rx=0.8,ry=0.8,angle=90,from=pi,to=2*pi,lwd=1) plotellipse(rx=0.8,ry=0.35,angle=-90,from=pi,to=2*pi,lwd=1) plotellipse(rx=0.8,ry=0.6,angle=-90,from=pi,to=2*pi,lwd=1) plotellipse(rx=0.8,ry=0.8,angle=-90,from=pi,to=2*pi,lwd=1) title("plotellipse, filledellipse") # emptyplot(c(-1,1)) col <- c(rev(greycol(n=50)),greycol(50)) filledellipse(rx1=1,rx2=0.5,dr=0.01,col=col) title("filledellipse") # emptyplot(c(-1,1),c(-1,1)) filledellipse(col=col) title("filledellipse") # color <-graycol(n=50) dr <- 0.05 emptyplot(xlim=c(-2,2),ylim=c(-2,2),col=color[length(color)]) filledellipse(rx1=1,mid=c(1,1) ,col=shadepalette(endcol="darkblue") ,dr=dr) filledellipse(rx1=1,mid=c(-1,-1),col=shadepalette(endcol="darkgreen"),dr=dr) filledellipse(rx1=1,mid=c(1,-1) ,col=shadepalette(endcol="darkred") ,dr=dr) filledellipse(rx1=1,mid=c(-1,1) ,col=shadepalette(endcol="darkviolet"),dr=dr) filledellipse(rx1=1,col=color,dr=dr) title("filledellipse") # color <-gray(seq(1,0.3,length.out=50)) emptyplot(xlim=c(-2,2),ylim=c(-2,2),col=color[length(color)]) filledellipse(rx1=2,ry1=0.4,col=color,angle=45,dr=dr) filledellipse(rx1=2,ry1=0.4,col=color,angle=-45,dr=dr) filledellipse(rx1=2,ry1=0.4,col=color,angle=0,dr=dr) filledellipse(rx1=2,ry1=0.4,col=color,angle=90,dr=dr) title("filledellipse") example(getellipse) # cylinder #---------------- example(cylindersegment) example(filledcylinder) # shape #---------------- emptyplot(c(-1.,1.)) xy <- getellipse(rx=1,ry=0.4) filledshape(xyouter=xy,xyinner=c(0,1.),col=femmecol(100)) title("filledshape") example(filledshape) emptyplot(col="darkgrey",main="filledshape") filledshape(matrix(nc=2,runif(100)),col=shadepalette(200,"darkred","darkblue")) # rectangle #---------------- example(filledrectangle) # multigonal #---------------- color <-shadepalette(grey(0.3),"blue",n=50) emptyplot(c(-1,1)) filledmultigonal(rx=0.25,ry=0.25,col=shadepalette(grey(0.3),"blue",n=50),nr=3,mid=c(0,0),angle=0) filledmultigonal(rx=0.25,ry=0.25,col=shadepalette(grey(0.3),"darkgreen",n=50),nr=4,mid=c(0.5,0.5),angle=90) filledmultigonal(rx=0.25,ry=0.25,col=shadepalette(grey(0.3),"orange",n=50),nr=5,mid=c(-0.5,-0.5),angle=-90) filledmultigonal(rx=0.25,ry=0.25,col="black",nr=6,mid=c(0.5,-0.5),angle=180) filledmultigonal(rx=0.25,ry=0.25,col="white",lcol="black",nr=7,mid=c(-0.5,0.5),angle=270) title("filledmultigonal") example(filledmultigonal) # Pipes xlim <- ylim <- c(-20,20) emptyplot(xlim) box() color <- graycol(n=5) color <- c(rev(color),color) maxlen <- 15 maxrad <- 1.0 dr <- 0.01 angle <- 0 mid <- c(0,0) ry <- 0 numpipes <- 100 for (i in 1:numpipes) { rnd <- runif(1) # jump length length <- maxlen*rnd newpos <- rotatexy(mid+c(length+2*maxrad,0),angle,mid) # check if within boundaries if (! (newpos[1] > xlim[1] & newpos[1] < xlim[2] & newpos[2] > ylim[1] & newpos[2] < ylim[2])) length <- 0 # rectangle mid <- rotatexy(mid+c(length/2,0),angle,mid) filledrectangle(wy=maxrad,wx=length,col=color,angle=angle,mid=mid) mid <- rotatexy(mid+c(length/2,0),angle,mid) rnd <- runif(1) # new angle dangle <- 0 if (rnd <= 0.3333) dangle <- 90 if (rnd >0.3333 & rnd < 0.6666) dangle <- - 90 piangle <- angle / 180 * pi if (dangle == 90) # left turn { mid <- rotatexy(mid+c(0,maxrad/2),angle,mid) filledcircle(r1=maxrad,r2=ry,col=color,mid=mid,dr=dr,from= piangle-pi/2,to= piangle) mid <- rotatexy(mid+c(maxrad/2,0),angle,mid) } if (dangle ==-90) # right turn { mid <- rotatexy(mid-c(0,maxrad/2),angle,mid) filledcircle(r1=maxrad,r2=ry,col=color,mid=mid,dr=dr,from= piangle,to= piangle+pi/2) mid <- rotatexy(mid+c(maxrad/2,0),angle,mid) } angle <- angle + dangle if (angle >= 360) angle <- angle - 360 if (angle < 0) angle <- angle + 360 } title("filledrectangle,filledcircle") # Arrowhead #---------------- emptyplot(c(0,1)) Arrowhead(x0=runif(10),y0=runif(10),angle=runif(10)*360, arr.length=0.4,arr.type="circle",arr.col="green") Arrowhead(x0=runif(10),y0=runif(10),angle=runif(10)*360, arr.length=0.6,arr.type="curved",arr.col="red") Arrowhead(x0=runif(10),y0=runif(10),angle=runif(10)*360, arr.length=0.6,arr.type="triangle",arr.col="blue") title("Arrowhead") # Arrows #---------------- example(Arrows) xlim <- c(-5 ,5) ylim <- c(-10,10) plot(0,type="n",xlim=xlim,ylim=ylim) x0<-runif(100,xlim[1],xlim[2]) y0<-runif(100,ylim[1],ylim[2]) x1<-x0+runif(100,-1,1) y1<-y0+runif(100,-1,1) size <- 0.6 ang <- runif(100,-360,360) Arrows(x0,y0,x1,y1,arr.length=size,code=2,arr.type="curved",arr.col="white") title("Arrows") plot(0,type="n",xlim=xlim,ylim=ylim) Arrows(x0,y0,x1,y1,arr.length=size,code=2,arr.type="triangle",arr.col="yellow") title("Arrows") plot(0,type="n",xlim=xlim,ylim=ylim) x0<-runif(100,xlim[1],xlim[2]) y0<-runif(100,ylim[1],ylim[2]) x1<-x0+runif(100,-1,1) y1<-y0+runif(100,-1,1) size <- 0.6 ang <- runif(100,-360,360) Arrows(x0,y0,x1,y1,arr.length=size,code=2,arr.type="circle",arr.col="darkblue") title("Arrows") # Lotka-Volterra competition model r1 <- 3 # parameters r2 <- 2 K1 <- 1.5 K2 <- 2 alf12 <- 1 alf21 <- 2 Ax <- c(0,K2/alf21) Ay <- K2 - alf21* Ax By <- c(0,K1/alf12) Bx <- K1 - alf12* By xlim <- range(c(Ax, Bx)) ylim <- range(c(Ay, By)) plot (x=Ax,y=Ay, type="l",lwd=3, # 1st isocline main="Arrows",sub="Model from Soetaert and Herman, 2008. book", xlab="N1",ylab="N2",xlim=xlim,ylim=ylim) lines (Bx,By, lty=2,lwd=3) # 2nd isocline gx <- seq(0,1.5,len=40) gy <- seq(0,2,len=40) N <- as.matrix(expand.grid(x=gx,y=gy)) dN1 <- r1*N[,1]*(1-(N[,1]+alf12* N[,2])/K1) dN2 <- r2*N[,2]*(1-(N[,2]+alf21* N[,1])/K2) dt <- 0.0001 Arrows(N[,1],N[,2],N[,1]+dt*dN1,N[,2]+dt*dN2,arr.len=0.15, lcol=grey(0.4),arr.type="triangle") points(x=c(0,0,1.5,0.5),y=c(0,2,0,1),pch=22,cex=2,bg=c("white","black","black","grey")) example(colorlegend) # Scientific example of use of filledellipse: uses values BW <- 10 # mmol/m3, oxygen concentration in surrounding water Da <- 0.5 # cm2/d effective diffusion coefficient in organism R <- 0.005 # cm radius of organism Q <- 250000 # nM/cm3/d oxygen consumption rate per volume per day # concentration in spherical organism body sphere <- function(Da,Q,BW,R,r) BW+Q/(6*Da)*(r^2-R^2) # distance in organism body color <- femmecol(100) zlim=c(0,BW) emptyplot(c(-3.3,3.3),col=color[length(color)],main="Oxygen concentration in spherical organism", sub="Model from Soetaert and Herman, 2008. book") R <- 0.005 values <- cbind(rr<-seq(0,R,length=50),sphere(Da,Q,BW,R,rr)) filledellipse(rx1=R*100,mid=c(-2,2),values=values,zlim=zlim,col=color,lcol="black",lwd=1) R <- 0.0075 values <- cbind(rr<-seq(0,R,length=50),sphere(Da,Q,BW,R,rr)) filledellipse(rx1=R*100,mid=c(0,2),values=values,zlim=zlim,col=color,lcol="black",lwd=1) R <- 0.010 values <- cbind(rr<-seq(0,R,length=50),sphere(Da,Q,BW,R,rr)) filledellipse(rx1=R*100,mid=c(2,2),values=values,zlim=zlim,col=color,lcol="black",lwd=1) R <- 0.015 values <- cbind(rr<-seq(0,R,length=100),sphere(Da,Q,BW,R,rr)) filledellipse(rx1=R*100,mid=c(-1,-1),values=values,zlim=zlim,col=color,lcol="black",lwd=1) segments(-1.5,-3,-0.5,-3,lwd=2,col="black") text(-1,-2.8,"10 microm") colorlegend(zlim=zlim,posy=c(0.05,0.5),posx=c(0.7,0.73),font=2, main="micromol/l",main.cex=1.2) shape/demo/00Index0000644000176200001440000000012210756577315013443 0ustar liggesuserscolorshapes Demonstration of colored shapes, color palettes, in package shape... shape/man/0000755000176200001440000000000013162156472012134 5ustar liggesusersshape/man/drapecol.Rd0000644000176200001440000000203211702565465014215 0ustar liggesusers\name{drapecol} \alias{drapecol} \title{ draping colors over a persp plot } \description{ generates color(s) that will appear on the surface facets of a "persp" plot. } \usage{ drapecol(A, col = femmecol(100), NAcol = "white", lim = NULL) } \arguments{ \item{A }{matrix with input grid. } \item{col }{color palette. } \item{NAcol }{color of \code{NA} elements. } \item{lim }{The limits of the data; if \code{NULL}, the data range will be chosen. } } \value{ a vector of character strings giving the colors in hexadecimal format, one for each surface facet. } \note{ This function is inspired by a similar function in package \code{fields}, unfortunately made unavailable in most recent version of fields } \author{ Karline Soetaert } \examples{ persp(volcano, theta = 135, phi = 30, col = drapecol(volcano), main = "drapecol") persp(volcano, theta = 135, phi = 30, col = drapecol(volcano), border = NA, main = "drapecol") } \seealso{ \code{\link{persp}} } \keyword{aplot} shape/man/roundrect.Rd0000644000176200001440000000262111702565471014432 0ustar liggesusers\name{roundrect} \alias{roundrect} \title{ adds a rounded rectangular box to a plot } \description{ adds a rectangular box with rounded left and right edges to a plot } \usage{ roundrect(mid, radx, rady, rx = rady, dr = 0.01, col = "white", lcol = "black", lwd = 2, angle = 0, ...) } \arguments{ \item{mid }{midpoint (x,y) of the box. } \item{radx }{horizontal radius of the box. } \item{rady }{vertical radius of the box. } \item{rx }{radius of rounded part. } \item{dr }{size of segments, in radians, to draw the rounded line (decrease for smoother). } \item{col }{fill color of the box. } \item{lcol }{line color surrounding box. } \item{lwd }{line width of line surrounding the box. } \item{angle }{rotation angle, degrees. } \item{... }{arguments passed to function \link{filledshape}. } } \author{Karline Soetaert } \examples{ emptyplot(c(-0.1, 1.1), main = "roundrect") for (i in 1:10) roundrect(mid = runif(2), col = i, radx = 0.1, rady = 0.05) for (i in 1:5) roundrect(mid = runif(2), col = greycol(20), radx = 0.05, rady = 0.05, angle = runif(1)*360) } \details{ \code{radx} and \code{rady} are the horizontal and vertical radiusses of the box; \code{rx} is the horizontal radius of the rounded part. Here \code{horizontal} and \code{vertical} denote the position BEFORE rotation. } \keyword{aplot} shape/man/filledellipse.Rd0000644000176200001440000001005714044727744015251 0ustar liggesusers\name{filledellipse} \alias{filledellipse} \title{ adds a colored and rotated ellipse to a plot } \description{ plots (part of) outer and inner ellipses and colors inbetween; color can be a palette } \usage{ filledellipse(rx1 = 1, rx2 = 0, ry1 = rx1, ry2 = NULL, mid = c(0,0), dr = 0.01, angle = 0, from = -pi, to = pi, col = femmecol(100), values = NULL, zlim = NULL, lwd = 2, lcol = NA, ...) } \value{ returns, as \code{invisible} a \code{list} containing "xyouter" and "xyinner", the points that define the outer and inner ellipse. } \arguments{ \item{rx1 }{horizontal radius of outer ellipse. } \item{rx2 }{horizontal radius of inner ellipse. } \item{ry1 }{vertical radius of outer ellipse. } \item{ry2 }{vertical radius of inner ellipse. } \item{mid }{midpoint of ellipse. } \item{dr }{size of segments, in radians, to draw ellipse (decrease for smoother). } \item{angle }{rotation angle, degrees. } \item{from }{starting angle for ellipse segment, radians. } \item{to }{final angle for ellipse segment, radians. The segment is drawn counterclockwise. The default is draw a full ellipse. } \item{col }{color palette to be used; also allowed are two extremes or one value. } \item{values }{if not \code{NULL}, a matrix providing (radius,z-values) couples, used for coloring. . } \item{zlim }{Only if \code{values} is not \code{NULL}: the minimum and maximum z values for which colors should be plotted, defaulting to the range of the finite values of the second column of \code{values}. } \item{lwd }{width of external line. } \item{lcol }{line color. } \item{... }{arguments passed to R-function \link{polygon}. } } \author{ Karline Soetaert } \examples{ color <- greycol(50) dr <- 0.05 emptyplot(xlim = c(-2, 2), ylim = c(-2, 2), col = color[length(color)], main = "filledellipse") filledellipse(rx1 = 1, mid = c(1, 1) , dr = dr, col = shadepalette(endcol = "darkblue")) filledellipse(rx1 = 1, ry1 = 0.5, mid = c(-1, -1), dr = dr, angle = 90, col = shadepalette(endcol = "darkred")) filledellipse(rx1 = 1, ry1 = 0.5, rx2 = 0.5, dr = dr, mid = c(0, 0), col = c(rev(color), color)) filledellipse(rx1 = 0.5, mid = c(1, -1), dr = dr, from = pi, to = 1.5*pi, col = rev(shadepalette(endcol = "black"))) filledellipse(mid = c(-1, 1)) emptyplot(xlim = c(-2, 2), ylim = c(-2, 2), main = "filledellipse") filledellipse(rx1 = 0.75, mid = c(-1, 1), col = greycol(100) , dr = dr, values = cbind (1:100, (1:100)^0.5)) filledellipse(rx1 = 0.75, mid = c(1, 1), col = greycol(100) , dr = dr, values = cbind (1:100, (1:100))) filledellipse(rx1 = 0.75, mid = c(-1, -1), col = greycol(100), dr = dr, values = cbind (1:100, (1:100)^2)) filledellipse(rx1 = 0.75, mid = c(1, -1), col = greycol(100) , dr = dr, values = cbind (1:100, (1:100)^5)) } \details{ draws (part of) an outer and inner ellipse, as specified by inner and outer radiusses: \code{rx1},\code{ry1}: horizontal and vertical radiusses of outer ellipse; \code{rx2},\code{ry2}: same for inner ellipse. Here "horizontal" and "vertical" denote the position BEFORE rotation Fills with a palette of colors inbetween \code{values}: if not \code{NULL}, a matrix providing (radius,z-values) couples, used for coloring. Here radius are positive values denoting the relative distance between the shapes centre and edge. The radiusses are rescaled to be in [0,1] if needed. z-values (2nd column of \code{values}) together with \code{zlim} and \code{col} denote the coloration level. Colors in \code{col} will be interpolated to the z-values and used to color an interval as given by the input radiusses. If \code{rx2}, the radius of the inner ellipse is 0, the ellipse is full. } \seealso{ \code{\link{filledshape}}, \code{\link{filledcylinder}} } \keyword{aplot} shape/man/filledmultigonal.Rd0000644000176200001440000001022314044727765015765 0ustar liggesusers\name{filledmultigonal} \alias{filledmultigonal} \title{ adds a colored and rotated multigonal shape to a plot } \description{ draws and colors a rotated shape with equal-sized vertices ; color can be a palette. } \usage{ filledmultigonal(mid = c(0, 0), rx = 1, ry = rx, nr = 4, col = femmecol(100), values = NULL, zlim = NULL, lwd = 2, lcol = NA, angle = 0, ...) } \arguments{ \item{mid }{midpoint of multigonal. } \item{rx }{horizontal radius. } \item{ry }{vertical radius. } \item{nr }{number of sides. } \item{col }{ color palette to be used; also allowed are two extremes or one value. } \item{values }{if not \code{NULL}, a matrix providing (radius,z-values) couples, used for coloring. } \item{zlim }{Only if \code{values} is not \code{NULL}: the minimum and maximum z values for which colors should be plotted, defaulting to the range of the finite values of the second column of \code{values}. } \item{lwd }{width of external line. } \item{lcol }{line color. } \item{angle }{angle of rotation, in degrees. } \item{... }{arguments passed to R-function \link{polygon}. } } \author{ Karline Soetaert } \examples{ emptyplot(c(-1, 1), main = "filledmultigonal") filledmultigonal(rx = 0.25, ry = 0.125, nr = 3, mid = c(-0.75, 0.75), angle = 45, col = shadepalette("red", "blue", n = 50)) filledmultigonal(rx = 0.125, ry = 0.25, nr = 3, mid = c(-0.25, 0.75), col = shadepalette("red", "yellow", n = 50)) filledmultigonal(rx = 0.25, ry = 0.25 , nr = 3, mid = c(0.25, 0.75), col = c("red", "orange")) filledmultigonal(rx = 0.25, ry = 0.25 , nr = 3, mid = c(0.75, 0.75), angle = 90, col = "red") filledmultigonal(rx = 0.25, ry = 0.25, nr = 4, mid = c(-0.75, 0.25), angle = 0, col = shadepalette("red", "blue", n = 50)) filledmultigonal(rx = 0.25, ry = 0.25, nr = 4, mid = c(-0.25, 0.25), angle = 45, col = shadepalette("red", "blue", n = 50)) filledmultigonal(rx = 0.25, ry = 0.125, nr = 4, mid = c(0.25, 0.25), angle = 0, col = shadepalette("red", "blue", n = 50)) filledmultigonal(rx = 0.25, ry = 0.125, nr = 4, mid = c(0.75, 0.25), angle = 45, col = shadepalette("red", "blue", n = 50)) filledmultigonal(rx = 0.25, ry = 0.25, nr = 5, mid = c(-0.75, -0.25), angle = 0, col = shadepalette("darkgreen", "lightgreen", n = 50)) filledmultigonal(rx = 0.25, angle = 0, nr = 5, mid = c(-0.25, -0.25), col = rainbow(50)) filledmultigonal(rx = 0.25, angle = 30, nr = 6, mid = c(0.25, -0.25), col = femmecol(50)) filledmultigonal(rx = 0.25, ry = 0.125, angle = 30, nr = 6, mid = c(0.75, -0.25), col = "black") filledmultigonal(rx = 0.25, col = "darkblue", nr = 7, mid = c(-0.75, -0.75)) filledmultigonal(rx = 0.25, col = "darkblue", nr = 9, mid = c(-0.25, -0.75)) filledmultigonal(rx = 0.25, col = "darkblue", nr = 3.7, mid = c(0.25, -0.75)) filledmultigonal(rx = 0.25, col = "darkblue", nr = 4.5, mid = c(0.75, -0.75)) } \details{ Coloration proceeds from midpoint to external edge \code{rx},\code{ry}: horizontal and vertical radiusses of the shape. Here "horizontal" and "vertical" denote the position BEFORE rotation \code{values}: if not \code{NULL}, a matrix providing (radius,z-values) couples, used for coloring. Here radius are positive values denoting the relative distance between the shapes centre and edge. The radiusses are rescaled to be in [0,1] if needed. z-values (2nd column of \code{values}) together with \code{zlim} and \code{col} denote the coloration level. Colors in \code{col} will be interpolated to the z-values and used to color an interval as given by the input radiusses. } \value{ returns, as \code{invisible} a \code{list} containing "xyouter" and "xyinner", the points that define the outer and inner ellipse. } \seealso{ \code{\link{filledrectangle}}, \code{\link{filledshape}}, \code{\link{filledcylinder}}, \code{\link{filledellipse}} } \keyword{aplot} shape/man/intpalette.Rd0000644000176200001440000000252311702565470014576 0ustar liggesusers\name{intpalette} \alias{intpalette} \title{color palettes} \description{ Returns color(s) that are a linear interpolation of a given set of colors. } \usage{ intpalette(inputcol, numcol = length(x.to), x.from = NULL, x.to = NULL) } \arguments{ \item{inputcol }{initial colors, *from* where to interpolate. } \item{numcol }{number of colors to interpolate *to*. } \item{x.from }{x-values *from* where to interpolate. } \item{x.to }{x-values where to interpolate *to*. } } \value{ a vector of character strings giving the interpolated colors in hexadecimal format } \author{ Karline Soetaert } \examples{ intpalette(c("white", "black"), n = 10) grey(seq(1, 0, length.out = 10)) image(matrix(nrow = 1,ncol = 100, data = 1:100), col = intpalette(c("red", "blue"), numcol = 100), main = "intpalette") image(matrix(nrow = 1, ncol = 100, data = 1:100), col = intpalette(c("red", "blue", "yellow"), numcol = 100), main = "intpalette") } \details{ Return value is a vector of *colors* in hexadecimal format. This is different from \code{\link[grDevices]{colorRamp}}(R function), that returns a *function* } \seealso{ \code{\link{greycol}}, \code{\link{femmecol}}, \code{\link{shadepalette}}, \code{\link[grDevices]{colorRamp}} for comparable R function } \keyword{color} shape/man/writelabel.Rd0000644000176200001440000000145211702565471014560 0ustar liggesusers\name{writelabel} \alias{writelabel} \title{ adds a label next to a plot } \description{ adds one-character label on left-upper margin, next to a plot } \usage{ writelabel(text = NULL, nr = 1, at = -0.1, line = 1, cex = 1.5, ...) } \arguments{ \item{text }{text to write. } \item{nr }{integer; if text = NULL: nr is converted to uppercase letter. } \item{at }{relative distance of label position, from left margin of plot region. } \item{line }{line above the plot region of label position. } \item{cex }{relative size of label. } \item{... }{arguments passed to R-function \link{mtext}. } } \author{ Karline Soetaert } \examples{ plot(runif(2), main = "writelabel") writelabel("A") writelabel("B", at = 0) writelabel("C", at = 1)} \keyword{aplot} shape/man/textflag.Rd0000644000176200001440000000424112425113412014226 0ustar liggesusers\name{textflag} \alias{textflag} \title{ adds a filled rounded rectangular box with a text to a plot } \description{ adds a rectangular box with rounded left and right edges to a plot } \usage{ textflag(mid, radx, rady, rx = rady, dr = 0.01, col = femmecol(100), lcol = "white", bcol = lcol, lwd = 2, angle = 0, lab = NULL, leftright = TRUE, tcol = NULL, ...) } \arguments{ \item{mid }{midpoint (x,y) of the box. } \item{radx }{horizontal radius of the box. } \item{rady }{vertical radius of the box. } \item{rx }{radius of rounded part. } \item{dr }{size of segments, in radians, to draw the rounded line (decrease for smoother). } \item{col }{fill color of the box; the box will be filled from left to right. } \item{lcol }{line color surrounding box. } \item{bcol }{line color to remove the ellipse from the rectangular box. } \item{tcol }{text color. } \item{lwd }{line width of line surrounding the box. } \item{angle }{rotation angle, degrees. } \item{lab }{one label or a vector string of labels to be added in box. } \item{leftright }{if \code{TRUE} then coloring is from left to right else the coloring is from bottom to top box (for \code{angle} = 0). } \item{... }{other arguments passed to function \link{text}. } } \author{Karline Soetaert } \examples{ emptyplot() textflag(mid = c(0.5, 0.5), radx = 0.5, rady = 0.1, lcol = "white", lab = "hello", cex = 5, font = 2:3) textflag(mid = c(0.5, 0.15), radx = 0.5, rady = 0.1, rx = 0.3,lcol = "black", lab = "hello 2", cex = 4, font = 2, angle = 20, tcol = "darkblue") textflag(mid = c(0.5, 0.85), radx = 0.5, rady = 0.1, rx = 0.03, lcol = "white", lab = "hello 3", cex = 4, font = 2, leftright = FALSE) } \details{ \code{radx} and \code{rady} are the horizontal and vertical radiusses of the box; \code{rx} is the horizontal radius of the rounded part. Here \code{horizontal} and \code{vertical} denote the position BEFORE rotation. This function is similar to function \link{roundrect}, except that coloring is from left to right. } \keyword{aplot} shape/man/filledcircle.Rd0000644000176200001440000000474514044744461015057 0ustar liggesusers\name{filledcircle} \alias{filledcircle} \title{ adds colored circle to a plot } \description{ plots (part of) outer and inner circle and colors inbetween; color can be a palette. } \usage{ filledcircle(r1 = 1, r2 = 0, mid = c(0,0), dr = 0.01, from = -pi, to = pi, col = femmecol(100), values = NULL, zlim = NULL, lwd = 2, lcol = NA, ...) } \arguments{ \item{r1 }{radius of outer circle. } \item{r2 }{radius of inner circle. } \item{mid }{midpoint of circle. } \item{dr }{size of segments, in radians, to draw circle (decrease for smoother). } \item{from }{starting angle for circle segment, radians. } \item{to }{final angle for circle segment, radians. The segment is drawn counterclockwise. The default is to draw a full circle. } \item{col }{color palette to be used; also allowed are two extremes or one value. } \item{values }{if not \code{NULL}, a matrix providing (radius,z-values) couples, used for coloring. . } \item{zlim }{Only if \code{values} is not \code{NULL}: the minimum and maximum z values for which colors should be plotted, defaulting to the range of the finite values of the second column of \code{values}. } \item{lwd }{width of external line. } \item{lcol }{line color. } \item{... }{arguments passed to R-function \link{polygon}. } } \author{ Karline Soetaert } \examples{ color <-graycol(n = 50) dr <- 0.05 emptyplot(xlim = c(-2, 2), col = color[length(color)], main = "filledcircle") filledcircle(r1 = 1, mid = c(1, 1), dr = dr, col = shadepalette(endcol = "darkblue")) filledcircle(r1 = 1, mid = c(-1, -1), dr = dr, col = shadepalette(endcol = "darkred")) filledcircle(r1 = 1, r2 = 0.5, mid = c(0, 0), dr = dr, col = c(rev(color), color)) filledcircle(r1 = 1, mid = c(1, -1), dr = dr, col = intpalette(c("red", "blue", "orange"), 100)) filledcircle(mid = c(-1, 1)) emptyplot(main = "filledcircle") for (i in seq(0, 0.45, 0.05)) filledcircle(r1 = i+0.05, r2 = i, mid = c(0.5, 0.5), col = i*20) } \value{ returns, as \code{invisible} a \code{list} containing "xyouter" and "xyinner", the points that define the outer and inner ellipse. } \details{ see \code{\link{filledellipse}} for details } \seealso{ \code{\link{filledshape}}, \code{\link{filledcylinder}}, \code{\link{filledellipse}} } \keyword{aplot} shape/man/Arrows.Rd0000644000176200001440000001275713432462306013710 0ustar liggesusers\name{Arrows} \alias{Arrows} \title{ adds arrows with improved arrowhead to a plot } \description{ adds one or more arrows to a plot; arrowhead shape is either curved, a triangle, a circle or simple } \usage{ Arrows(x0, y0, x1, y1, code = 2, arr.length = 0.4, arr.width = arr.length/2, arr.adj = 0.5, arr.type = "curved", segment = TRUE, col = "black", lcol = col, lty = 1, arr.col = lcol, lwd = 1, arr.lwd = lwd, ...) } \arguments{ \item{x0 }{x-coordinates of points *from* which to draw arrows; either one value or a vector. } \item{y0 }{y-coordinates of points *from* which to draw arrows; either one value or a vector. } \item{x1 }{x-coordinates of points *to* which to draw arrows; either one value or a vector. } \item{y1 }{y-coordinates of points *to* which to draw arrows; either one value or a vector. } \item{code }{integer code determining kind of arrows to draw. } \item{arr.length }{approximate length of arrowhead, in cm; either one value or a vector. } \item{arr.width }{approximate width of arrowhead, in cm; either one value or a vector. } \item{arr.adj }{0,0.5,1 specifying the adjustment of the arrowhead. } \item{arr.type }{type of arrowhead to draw, one of "none", "simple", "curved", "triangle", "circle", "ellipse" or "T". } \item{segment }{logical specifying whether or not to draw line segments. } \item{col }{general line color specification; one value or a vector. } \item{lcol }{line color specifications; either one value or a vector. ignored when arr.type = \code{"simple"} or \code{"T"} - use "col" } \item{lty }{line type specifications; either one value or a vector. } \item{arr.col }{color of arrowhead; either one value or a vector. } \item{lwd }{general line width specification. The default value changed to 1 from version 1.4 (was 2) } \item{arr.lwd }{line width of arrowhead. } \item{... }{arguments passed to lines, segments or \link{Arrowhead} function. } } \author{ Karline Soetaert } \examples{ xlim <- c(-5 , 5) ylim <- c(-10, 10) plot(0, type = "n", xlim = xlim, ylim = ylim, main = "Arrows, type = 'curved'") x0 <- runif(100, xlim[1], xlim[2]) y0 <- runif(100, ylim[1], ylim[2]) x1 <- x0+runif(100, -1, 1) y1 <- y0+runif(100, -1, 1) Arrows(x0, y0, x1, y1, arr.length = runif(100), code = 2, arr.type = "curved", arr.col = 1:100, lcol = 1:100) plot(0, type = "n", xlim = xlim, ylim = ylim, main = "Arrows, type = 'circle'") x0 <- runif(100, xlim[1], xlim[2]) y0 <- runif(100, ylim[1], ylim[2]) x1 <- x0 + runif(100, -1, 1) y1 <- y0 + runif(100, -1, 1) Arrows(x0, y0, x1, y1, arr.length = 0.2, code = 3, arr.type = "circle", arr.col = "grey") plot(0, type = "n", xlim = xlim, ylim = ylim, main = "Arrows, type = 'ellipse'") Arrows(x0, y0, x1, y1, arr.length = 0.2, arr.width = 0.5, code = 3, arr.type = "ellipse", arr.col = "grey") curve(expr = sin(x), 0, 2*pi+0.25, main = "Arrows") x <- seq(0, 2*pi, length.out = 10) xd <- x + 0.025 Arrows(x, sin(x), xd, sin(xd), type = "triangle", arr.length = 0.5, segment = FALSE) xx <- seq(0, 10*pi, length.out = 1000) plot(sin(xx)*xx, cos(xx)*xx, type = "l", axes = FALSE, xlab = "", ylab = "", main = "Arrows, type = 'curved'") x <- seq(0, 10*pi, length.out = 20) x1 <- sin(x)*x y1 <- cos(x)*x xd <- x+0.01 x2 <- sin(xd)*xd y2 <- cos(xd)*xd Arrows(x1, y1, x2, y2, arr.type = "curved", arr.length = 0.4, segment = FALSE, code = 1, arr.adj = 0.5 ) plot(sin(xx)*xx, cos(xx)*xx, type = "l", axes = FALSE, xlab = "", ylab = "", main = "Arrows, type = 'T'") Arrows(x1, y1, x2, y2, arr.type = "T", arr.length = 0.4, code = 1, arr.lwd = 2) # arguments passed to polygon: xlim <- c(-5 , 5) ylim <- c(-10, 10) plot(0, type = "n", xlim = xlim, ylim = ylim, main = "Arrows, type = 'curved'") x0 <- runif(100, xlim[1]-1, xlim[2]+0.5) # exceeds the x-range y0 <- runif(100, ylim[1], ylim[2]) x1 <- x0+runif(100, -1, 1) y1 <- y0+runif(100, -1, 1) Arrows(x0, y0, x1, y1, arr.length = runif(100), code = 2, arr.type = "curved", arr.col = 1:100, lcol = 1:100, xpd = TRUE) } \details{ \code{x0}, \code{y0}, \code{x1}, \code{y1}, \code{arr.length}, \code{arr.width}, \code{arr.adj}, \code{lcol}, \code{lty} and \code{arr.col} can be a vector, of the same length. For each 'i', an arrow is drawn between the point '(x0[i], y0[i])' and the point '(x1[i],y1[i])'. \itemize{ \item If \code{code}=1 an arrowhead is drawn at '(x0[i],y0[i])' \item if \code{code}=2 an arrowhead is drawn at '(x1[i],y1[i])'. \item If \code{code}=3 an arrowhead is drawn at both ends of the arrow \item unless \code{arr.length} = 0, when no head is drawn. } \itemize{ \item If \code{arr.adj} = 0.5 then the centre of the arrowhead is at the point at which it is drawn. \item \code{arr.adj} = 1 causes the tip of the arrowhead to touch the point. \item \code{arr.adj} = 2 causes the base of the arrowhead to touch the point. } The type of the arrowhead is set with \code{arr.type} which can take the values: \itemize{ \item "simple" : uses comparable \R function \link{arrows} \item "triangle": uses filled triangle \item "curved" : draws arrowhead with curved edges \item "circle" : draws circular head \item "ellipse" : draws ellepsoid head \item "T" : draws T-shaped (blunt) head } } \seealso{ \code{\link{arrows}} the comparable R function \code{\link{Arrowhead}} } \keyword{aplot} shape/man/shape.Rd0000644000176200001440000000406111620243114013507 0ustar liggesusers\name{shape-package} \alias{shape-package} \alias{shape} \docType{package} \title{ Functions for plotting graphical shapes, colors } \description{ Functions for plotting graphical shapes such as ellipses, circles, cylinders, arrows, ... Support for the book "A practical guide to ecological modelling - using R as a simulation platform" by Karline Soetaert and Peter M.J. Herman (2009). Springer. } \details{ \tabular{ll}{ Package: \tab shape\cr Type: \tab Package\cr Version: \tab 1.3.4\cr Date: \tab 2011-07-30\cr License: \tab GNU Public License 3 or above\cr } This package is used in R-package ecolMod, which includes many more examples. See also R-package diagram. Changes in version 1.3.4: more consistent drawing of ellipse and circle segments, (functions getellipse, getcircle), added textflag. (both suggested by Tom Wilson) } \author{ Karline Soetaert (Maintainer) } \seealso{ \code{\link{A4}}, \code{\link{writelabel}}, \code{\link{emptyplot}}, \code{\link{drapecol}}, \code{\link{femmecol}}, \code{\link{intpalette}}, \code{\link{shadepalette}}, \code{\link{colorlegend}}, \code{\link{greycol}}, \code{\link{rotatexy}}, \code{\link{Arrowhead}}, \code{\link{Arrows}}, \code{\link{cylindersegment}}, \code{\link{filledcylinder}}, \code{\link{filledcircle}}, \code{\link{filledellipse}}, \code{\link{filledmultigonal}}, \code{\link{filledrectangle}}, \code{\link{filledshape}}, \code{\link{getellipse}}, \code{\link{plotcircle}}, \code{\link{plotellipse}}, \code{\link{roundrect}}, \code{\link{textflag}}. } \examples{ \dontrun{ ## show examples (see respective help pages for details) example(rotatexy) example(filledshape) ## run demos demo("colorshapes") # creating colored shapes ## open the directory with source code of demos browseURL(paste(system.file(package="shape"), "/demo", sep="")) ## show package vignette vignette("shape") edit(vignette("shape")) browseURL(paste(system.file(package="shape"), "/doc", sep="")) } } \keyword{ package }shape/man/emptyplot.Rd0000644000176200001440000000142311702565465014464 0ustar liggesusers\name{emptyplot} \alias{emptyplot} \title{open a plot without axes, labels,...} \description{ Creates a plotting region, bounded by xlim and ylim; without axes, labels, titles, useful for plotting shapes. } \usage{ emptyplot(xlim = c(0, 1), ylim = xlim, asp = 1, frame.plot = FALSE, col = NULL, ...) } \arguments{ \item{xlim }{the x limits (min,max) of the plot. } \item{ylim }{the y limits (min,max) of the plot. } \item{asp }{the y/x aspect ratio. } \item{frame.plot }{to toggle off drawing of a bounding box. } \item{col }{the background color. } \item{... }{arguments passed to R-function \link{plot}. } } \author{ Karline Soetaert } \seealso{ \code{\link{plot}}, \code{\link{plot.default}} } \keyword{hplot} shape/man/femmecol.Rd0000644000176200001440000000141611702565465014220 0ustar liggesusers\name{femmecol} \alias{femmecol} \title{red-green-blue color palette} \description{ Creates a vector of (n) contiguous colors (darkblue-blue-cyan-yellow-red-darkred). } \usage{ femmecol(n = 100) } \arguments{ \item{n }{number of colors. } } \value{ a vector of character strings giving the colors in hexadecimal format } \author{ Karline Soetaert } \examples{ filled.contour(volcano, color = femmecol, asp = 1, main = "femmecol") femmecol(10) image(matrix(nrow = 1, ncol = 100, data = 1:100), col = femmecol(100), main = "femmecol") } \seealso{ \code{\link{rainbow}}, \code{\link{heat.colors}}, \code{\link{topo.colors}}, the comparable R-functions. \code{\link{intpalette}}, \code{\link{shadepalette}} } \keyword{color} shape/man/filledcylinder.Rd0000644000176200001440000000652211702565466015426 0ustar liggesusers\name{filledcylinder} \alias{filledcylinder} \title{ adds a colored and rotated cylinder to a plot } \description{ adds a rotated and colored cylinder to a plot; color can be a palette } \usage{ filledcylinder(rx = 1, ry = rx, len = 1, col = femmecol(100), lcol = NA, lwd = 2, lcolint = NULL, ltyint = 1, lwdint = lwd, mid = c(0,0), angle = 0, delt = 1, dr = 0.01, topcol = NULL, botcol = NULL, ...) } \arguments{ \item{rx }{horizontal radius. } \item{ry }{vertical radius. } \item{len }{length. } \item{col }{color palette to be used; also allowed are two extremes or one value. } \item{lcol }{line color on external surface. } \item{lwd }{only if lcol!=NA, width of external line. } \item{lcolint }{only if lcol!=NA, line color on internal (hidden) surface. } \item{ltyint }{only if lcol!=NA, line type on internal (hidden) surface. } \item{lwdint }{only if dlcol!=NA, line width on internal (hidden) surface. } \item{mid }{midpoint of cylinder. } \item{angle }{rotation angle, degrees. } \item{delt }{increase factor, from left to right. } \item{dr }{size of segments, in radians, to draw top/bottom ellipse (decrease for smoother). } \item{topcol }{color (palette) of top (right) surface. } \item{botcol }{color (palette) of bottom (left) surface. } \item{... }{arguments passed to function \link{filledellipse}. } } \author{ Karline Soetaert } \examples{ emptyplot(c(-1.2, 1.2), c(-1, 1), main = "filledcylinder") col <- c(rev(greycol(n = 50)), greycol(n = 50)) col2 <- shadepalette("red", "blue", n = 50) col3 <- shadepalette("yellow", "black", n = 50) filledcylinder(rx = 0., ry = 0.2, len = 0.25, angle = 0, col = col, mid = c(-1, 0), topcol = col[25]) filledcylinder(rx = 0., ry = 0.2, angle = 90, col = col, mid = c(-0.5, 0), topcol = col[25]) filledcylinder(rx = 0.1, ry = 0.2, angle = 90, col = c(col2, rev(col2)), mid = c(0.45, 0), topcol = col2[25]) filledcylinder(rx = 0.05, ry = 0.2, angle = 90, col = c(col3, rev(col3)), mid = c(0.9, 0), topcol = col3[25]) filledcylinder(rx = 0.1, ry = 0.2, angle = 90, col = "white", lcol = "black", lcolint = "grey") emptyplot(c(-1, 1), c(-1, 1), main = "filledcylinder") col <- shadepalette("blue", "black", n = 50) col2 <- shadepalette("red", "black", n = 50) col3 <- shadepalette("yellow", "black", n = 50) filledcylinder(rx = 0.025, ry = 0.2, angle = 90, col = c(col2, rev(col2)), mid = c(-0.8, 0), topcol = col2[25], delt = -1, lcol = "black") filledcylinder(rx = 0.1, ry = 0.2, angle = 00, col = c(col, rev(col)), mid = c(0.0, 0.0), topcol = col, delt = -1.2, lcol = "black") filledcylinder(rx = 0.075, ry = 0.2, angle = 90, col = c(col3, rev(col3)), mid = c(0.8, 0), topcol = col3[25], delt = 0.0, lcol = "black") } \details{ When angle = 0 (the default), the cylinder is parallel to the x-axis \code{rx} and \code{ry} are the horizontal and vertical radiusses of the bordering ellipses. Here "horizontal" and "vertical" denote the position BEFORE rotation if \code{delt} > 1, the width of the cylinder will increase from left to right. } \seealso{ \code{\link{filledellipse}}, \code{\link{filledshape}} } \keyword{aplot} shape/man/plotellipse.Rd0000644000176200001440000000640311702565470014762 0ustar liggesusers\name{plotellipse} \alias{plotellipse} \title{ adds part of a colored and rotated ellipse to a plot } \description{ adds (part of) a colored, and rotated ellipse to a plot; an arrow can be drawn at a specified position. } \usage{ plotellipse(rx = 1, ry = 0.2, mid = c(0,0), dr = 0.01, angle = 0, from = -pi, to = pi, type = "l", lwd = 2, lcol = "black", col = NULL, arrow = FALSE, arr.length = 0.4, arr.width = arr.length*0.5, arr.type = "curved", arr.pos = 1, arr.code = 2, arr.adj = 0.5, arr.col = "black", ...) } \arguments{ \item{rx }{long radius of ellipse. } \item{ry }{short radius of ellipse. } \item{mid }{midpoint of ellipse. } \item{dr }{size of segments, in radians, to draw ellipse (decrease for smoother). } \item{angle }{rotation angle, degrees. } \item{from }{starting angle for ellipse segment, radians. } \item{to }{final angle for ellipse segment, radians. } \item{type }{external line or points; "n" if no line. } \item{lwd }{width of external line. } \item{lcol }{line color. } \item{col }{fill color. } \item{arrow }{drawing arrowhead yes/no. } \item{arr.length }{length of arrowhead. } \item{arr.width }{width of arrowhead. } \item{arr.type }{type of arrow. } \item{arr.pos }{position of arrow, 0=start,1=end. } \item{arr.code }{integer code determining kind of arrows to draw. } \item{arr.adj }{adjustment of arrow. } \item{arr.col }{color of arrow head. } \item{... }{arguments passed to R-function \link{lines}. } } \author{ Karline Soetaert } \examples{ emptyplot(c(-1, 1), main = "plotellipse") plotellipse(rx = 0.8, ry = 0.3, angle = 60, col = "blue") plotellipse(rx = 1.0, ry = 0.6, angle = 0, from = pi, to = 2*pi, arrow = TRUE, arr.pos = seq(0.1, 0.5, by = 0.1), arr.col = rainbow(5)) plotellipse(rx = 1.0, ry = 0.6, angle = 30, from = pi, to = 1.2*pi, col = "red") plotellipse(rx = 0.1, ry = 0.6, from = 1.5*pi, to = pi, lcol = "orange", mid = c(0.2,0.2)) plotellipse(rx = 0.1, ry = 0.6, angle = 30, from = 1.5*pi, to = pi, lcol = "orange", mid = c(0.2,0.2)) } \details{ \code{rx} and \code{ry} are the horizontal and vertical radiusses of the ellipses. The ellipse is drawn from the point defined by \code{from} to the point defined as \code{to} which are joined anti-clockwise. if \code{arrow} is \code{TRUE}, an arrow is drawn along the path of the ellipse. \code{arr.length} and \code{arr.width} set the size of the arrow. The type of the arrowhead is set with \code{arr.type} which can take the values: \itemize{ \item "simple" : uses comparable \R function \link{arrows}. \item "triangle": uses filled triangle. \item "curved" : draws arrowhead with curved edges. \item "circle" : draws circular head. } \code{arr.pos}, a real value between 0 and 1 gives the position (0=start,1=end). \code{arr.col} specifies the color, \code{arr.code} specifies where the angle points to. \code{arr.adj} specifies the position adjustment - see \code{\link{Arrows}} for details. } \seealso{ \code{\link{getellipse}}, \code{\link{filledellipse}}, \code{\link{plotcircle}}. } \keyword{aplot} shape/man/filledrectangle.Rd0000644000176200001440000000621111702565467015555 0ustar liggesusers\name{filledrectangle} \alias{filledrectangle} \title{ adds a colored and rotated rectangle to a plot } \description{ plots and colors a rotated rectangle; color can be a palette } \usage{ filledrectangle(mid = c(0, 0), wx = 1, wy = wx, col = femmecol(100), values = NULL, zlim = NULL, lwd = 2, lcol = NA, angle = 0, ...) } \arguments{ \item{mid }{midpoint of rectangle. } \item{wx }{horizontal width. } \item{wy }{vertical width. } \item{col }{color palette to be used; also allowed are two extremes or one value. } \item{values }{ if not \code{NULL}, a matrix providing (radius,z-values) couples, used for coloring. } \item{zlim }{ Only if values is not NULL: the minimum and maximum z values for which colors should be plotted, defaulting to the range of the finite values of the second column of \code{values}. } \item{lwd }{width of external line. } \item{lcol }{line color. } \item{angle }{angle of rotation, in degrees. } \item{... }{arguments passed to R-function \link{polygon}. } } \author{ Karline Soetaert } \examples{ color <- shadepalette(grey(0.3), "lightblue", n = 50) emptyplot(main = "filledrectangle") filledrectangle(wx = 0.5, wy = 0.5, col = color, mid = c(0.5, 0.5), angle = 0) filledrectangle(wx = 0.25, wy = 0.25, col = "darkblue", mid = c(0.5, 0.5), angle = 45) filledrectangle(wx = 0.125, wy = 0.125, col = c("lightblue","blue"), mid = c(0.5, 0.5), angle = 90) color <- shadepalette(grey(0.3), "blue", n = 50) emptyplot(c(-1, 1), main = "filledrectangle") filledrectangle(wx = 0.5, wy = 0.5, col = color, mid = c(0, 0), angle = 0) filledrectangle(wx = 0.5, wy = 0.5, col = color, mid = c(0.5, 0.5), angle = 90) filledrectangle(wx = 0.5, wy = 0.5, col = color, mid = c(-0.5, -0.5), angle = -90) filledrectangle(wx = 0.5, wy = 0.5, col = color, mid = c(0.5, -0.5), angle = 180) filledrectangle(wx = 0.5, wy = 0.5, col = color, mid = c(-0.5, 0.5), angle = 270) } \details{ If \code{angle}=0, coloration starts from top to bottom. This is different from \code{\link{filledmultigonal}}, where coloration proceeds from middle to external \code{wx},\code{wy}: horizontal and vertical width of the shape Here "horizontal" and "vertical" denote the position BEFORE rotation \code{values}: if not \code{NULL}, a matrix providing (radius,z-values) couples, used for coloring. Here radius are positive values denoting the relative distance between the shapes centre and edge. The radiusses are rescaled to be in [0,1] if needed. z-values (2nd column of \code{values}) together with \code{zlim} and \code{col} denote the coloration level. Colors in \code{col} will be interpolated to the z-values and used to color an interval as given by the input radiusses. } \seealso{ \code{\link{filledmultigonal}}, \code{\link{filledshape}}, \code{\link{filledcylinder}}, \code{\link{filledellipse}} \code{\link{polygon}}, \code{\link{rect}} for corresponding R-functions. } \keyword{aplot} shape/man/rotatexy.Rd0000644000176200001440000000230611702565470014303 0ustar liggesusers\name{rotatexy} \alias{rotatexy} \title{ rotates 2-column matrix around a midpoint } \description{ rotates xy values around a midpoint; xy is either a 2-columned matrix or a 2-valued vector } \usage{ rotatexy(xy, angle, mid = colMeans(xy), asp = FALSE) } \arguments{ \item{xy }{matrix with 2 columns, or a 2-valued vector to be rotated. } \item{angle }{angle of rotation, in degrees. } \item{mid }{rotation point, default=centroid. } \item{asp }{if true: aspect ratio is kept. } } \value{ a 2-column matrix with rotated values } \author{ Karline Soetaert } \examples{ x <- seq(0, 2*pi, pi/100) y <- sin(x) cols <- intpalette(c("blue", "green", "yellow", "red"), n = 500) cols <- c(cols,rev(cols)) plot(x, y, type = "l", ylim = c(-3, 3), main = "rotatexy", col = cols[1], lwd = 2) for (i in 2:1000) lines(rotatexy( cbind(x, y), angle = 0.18*i), col = cols[i], lwd = 2) cols <- femmecol(1000) plot(x, y, xlim = c(-1, 1), ylim = c(-1, 1), main = "rotatexy", col = cols[1], type = "n") for (i in 2:1000) { xy <- rotatexy(c(0, 1), angle = 0.36*i, mid = c(0,0)) points(xy[1], xy[2], col = cols[i], pch = ".", cex = 2) } } \keyword{manip} shape/man/A4.Rd0000644000176200001440000000044011702565463012667 0ustar liggesusers\name{A4} \alias{A4} \title{opens A4-sized window} \description{ opens a graphics window, 8.5 inches wide, 11 inches high } \usage{ A4 (...) } \arguments{ \item{... }{arguments passed to R-function X11. } } \author{Karline Soetaert } \keyword{device} shape/man/getellipse.Rd0000644000176200001440000000375611702565467014601 0ustar liggesusers\name{getellipse} \alias{getellipse} \title{ x-y coordinates of ellipse } \description{ calculates x-y values for (part of) an ellipse; the ellipse can be rotated } \usage{ getellipse(rx = 1, ry = rx, mid = c(0, 0), dr = 0.01, angle = 0, from = -pi, to = pi) } \arguments{ \item{rx }{long radius of ellipse. } \item{ry }{short radius of ellipse. } \item{mid }{midpoint of ellipse. } \item{dr }{size of segments, in radians, to specify ellipse (decrease for smoother). } \item{angle }{rotation angle, degrees. } \item{from }{starting angle for ellipse segment, radians. } \item{to }{final angle for ellipse segment, radians. The segment is generated counterclockwise. The default is draw a full ellipse. } } \value{ a 2-column matrix with x-y values of the ellipse } \author{ Karline Soetaert } \examples{ plot(getellipse(1, from = 0, to = pi/2), type = "l", col = "red", lwd = 2, main = "getellipse") lines(getellipse(0.5, 0.25, mid = c(0.5, 0.5)), type = "l", col = "blue", lwd = 2) lines(getellipse(0.5, 0.25, mid = c(0.5, 0.5), angle = 45), type = "l", col = "green", lwd = 2) lines(getellipse(0.2, 0.2, mid = c(0.5, 0.5), from = 0, to = pi/2), type = "l", col = "orange", lwd = 2) lines(getellipse(0.2, 0.2, mid = c(0.5, 0.5), from = pi/2, to = 0), type = "l", col = "black", lwd = 2) lines(getellipse(0.1, 0.1, mid = c(0.75, 0.5), from = -pi/2, to = pi/2), type = "l", col = "black", lwd = 2) emptyplot(main = "getellipse") col <- femmecol(90) for (i in seq(0, 180, by = 2)) lines(getellipse(0.5, 0.25, mid = c(0.5, 0.5), angle = i), type = "l", col = col[(i/2)+1], lwd = 2) } \details{ \code{rx} and \code{ry} are the horizontal and vertical radiusses of the ellipses. points \code{from} and \code{to} are joined counterclockwise. (this has changed since version 1.3.4). } \seealso{ \code{\link{plotellipse}}, \code{\link{filledellipse}} } \keyword{dplot} shape/man/colorlegend.Rd0000644000176200001440000000523311702565464014726 0ustar liggesusers\name{colorlegend} \alias{colorlegend} \title{ adds a color legend to a plot. } \description{ Adds a color legend to a plot. } \usage{ colorlegend(col = femmecol(100), zlim, zlevels = 5, dz = NULL, zval = NULL, log = FALSE, posx = c(0.9, 0.93), posy = c(0.05, 0.9), main = NULL, main.cex = 1.0, main.col = "black", lab.col = "black", digit = 0, left = FALSE, ...) } \arguments{ \item{col }{color palette to be used; also allowed are two extremes or one value. } \item{zlim }{two-valued vector, the minimum and maximum z values. } \item{zlevels }{number of z-levels, one value, ignored if \code{dz} or \code{zval} not equal to \code{NULL}. } \item{dz }{increment in legend values, one value; ignored if \code{zval} not equal to \code{NULL}. } \item{zval }{a vector of z-values to label legend. } \item{log }{logical indicating whether to log transform or not. } \item{posx }{relative position of left and right edge of color bar on first axis, [0,1]. } \item{posy }{relative position on lower and upper edge of colar bar on second axis, [0,1]. } \item{main }{main title, written above the color bar. } \item{main.cex }{relative size of main title. } \item{main.col }{color of main title. } \item{lab.col }{color of labels. } \item{digit }{number of significant digits in labels. } \item{left }{logical indicating whether to put the labels on the right (\code{TRUE}) or on the left (\code{FALSE}). } \item{... }{arguments passed to R-function \link{text} when writing labels. } } \author{ Karline Soetaert } \examples{ emptyplot(main = "colorlegend") colorlegend(zlim = c(0, 10)) colorlegend(posx = c(0.8, 0.83), col = greycol(100), zlim = c(0, 1), digit = 1) colorlegend(posx = c(0.7, 0.73), left = TRUE, col = rainbow(100), zlim = c(0, 10), digit = 1, dz = 2.5) colorlegend(posx = c(0.5, 0.53), col = intpalette(c("red", "yellow", "black"), 100), zlim = c(0, 20), zval = c(1, 3, 7, 15)) colorlegend(posy = c(0.0, 0.15), posx = c(0.2, 0.3), col = rainbow(100), zlim = c(0, 1), zlevels = NULL, main = "rainbow") colorlegend(posy = c(0.25, 0.4), posx = c(0.2, 0.3), zlim = c(0, 1), zlevels = NULL, main = "femmecol") colorlegend(posy = c(0.5, 0.65), posx = c(0.2, 0.3), col = terrain.colors(100), zlim = c(0, 1), zlevels = NULL, main = "terrain.colors") colorlegend(posy = c(0.75, 0.9), posx = c(0.2, 0.3), col = heat.colors(100), zlim = c(0, 1), zlevels = NULL, main = "heat.colors") } \keyword{aplot} shape/man/filledshape.Rd0000644000176200001440000000545111702565467014716 0ustar liggesusers\name{filledshape} \alias{filledshape} \title{ adds a colored shape to a plot } \description{ plots outer and inner shape and colors inbetween; color can be a palette } \usage{ filledshape(xyouter, xyinner = colMeans(xyouter), col = femmecol(100), values = NULL, zlim = NULL, lcol = NA, lwd = 2, ...) } \arguments{ \item{xyouter }{2-column matrix with x,y values of outer shape. } \item{xyinner }{2-column matrix of 2-valued vector with x,y values of inner shape; default is centroid of \code{xyouter}. } \item{col }{color palette to be used; also allowed are two extremes. } \item{values }{if not \code{NULL}, a matrix providing (radius,z-values) couples, used for coloring. } \item{zlim }{ Only if \code{values} is not \code{NULL}: the minimum and maximum z values for which colors should be plotted, defaulting to the range of the finite values of the second column of *values*. } \item{lcol }{line color. } \item{lwd }{width of external line, only if \code{lcol} != \code{NA}. } \item{... }{arguments passed to R-function \link{polygon}} } \author{ Karline Soetaert } \examples{ #an egg color <-greycol(100) emptyplot(c(-3.2, 3.2), col = color[length(color)], main = "filledshape") b <- 4 a <- 9 x <- seq(-sqrt(a), sqrt(a), by = 0.01) g <- b-b/a*x^2 - 0.2*b*x + 0.2*b/a*x^3 g[g<0] <- 0 x1 <- c(x, rev(x)) g1 <- c(sqrt(g), rev(-sqrt(g))) xouter <- cbind(x1, g1) xouter <- rbind(xouter, xouter[1,]) filledshape(xouter, xyinner = c(-1, 0), col = color) # a mill color <- shadepalette(grey(0.3), "yellow", n = 50) emptyplot(c(-3.3, 3.3), col = color[length(color)], main = "filledshape") x <- seq(0, 0.8*pi, pi/100) y <- sin(x) xouter <- cbind(x, y) for (i in seq(0, 360, 60)) xouter <- rbind(xouter, rotatexy(cbind(x, y), mid = c(0, 0), angle = i)) filledshape(xouter, c(0, 0), col = color) # abstract art emptyplot(col = "darkgrey", main = "filledshape") filledshape(matrix(ncol = 2, runif(100)), col = "darkblue") } \details{ draws and outer and inner shape, as specified in \code{xyouter}, and \code{xyinner} and fills with a palette of colors inbetween; \code{values}: if not null, a matrix providing (radius,z-values) couples, used for coloring. Here radius are positive values denoting the relative distance between the shapes centre and edge. The radiusses are rescaled to be in [0,1] if needed. z-values (2nd column of \code{values}) together with \code{zlim} and \code{col} denote the coloration level. Colors in \code{col} will be interpolated to the z-values and used to color an interval as given by the input radiusses. If \code{xyinner} is a point, the shape is full. } \seealso{ \code{\link{filledellipse}}, \code{\link{filledcylinder}} } \keyword{aplot} shape/man/greycol.Rd0000644000176200001440000000153011702565467014074 0ustar liggesusers\name{greycol} \alias{greycol} \alias{graycol} \title{ white-black color palette } \description{ Creates a vector of (n) contiguous colors from white/grey to black } \usage{ greycol(n = 100, interval = c(0.0, 0.7)) } \arguments{ \item{n }{number of colors. } \item{interval }{interval *to* where to interpolate. } } \value{ a vector of character strings giving the colors in hexadecimal format. } \author{ Karline Soetaert } \examples{ filled.contour(volcano, color = graycol, asp = 1, main = "greycol,graycol") graycol(10) image(matrix(nrow = 1, ncol = 100, data = 1:100), col = graycol(100), main = "greycol,graycol") } \details{ greycol is an alias of graycol } \seealso{ \code{\link{rainbow}}, \code{\link{heat.colors}}, \code{\link{topo.colors}}, \code{\link{femmecol}} } \keyword{color} shape/man/shadepalette.Rd0000644000176200001440000000174511702565471015076 0ustar liggesusers\name{shadepalette} \alias{shadepalette} \title{ color palette inbetween two extremes } \description{ Returns color(s) that are a linear interpolation between two colors these colors are suitable for shading shapes } \usage{ shadepalette(n = 100, endcol = "red", inicol = "white", interval = c(0.0, 1.0)) } \arguments{ \item{n }{number of colors. } \item{endcol }{final color. } \item{inicol }{initial color. } \item{interval }{interval *to* where to interpolate. } } \value{ a vector of character strings giving the interpolated colors in hexadecimal format } \author{ Karline Soetaert } \examples{ shadepalette(n = 10, "white", "black") image(matrix(nrow = 1, ncol = 100, data = 1:100), col = shadepalette(100, "red", "blue"), main = "shadepalette") } \seealso{ \code{\link{intpalette}}, \code{\link{grey}}, \code{\link{femmecol}} \code{\link[grDevices]{colorRamp}} for comparable R functions. } \keyword{color} shape/man/cylindersegment.Rd0000644000176200001440000000415411702565465015627 0ustar liggesusers\name{cylindersegment} \alias{cylindersegment} \title{ adds part of a cylinder to a plot } \description{ adds a segment of a cylinder to a plot } \usage{ cylindersegment(rx = 1, ry = rx, from = pi, to = 3*pi/2, len = 1, mid = c(0,0), angle = 0, dr = 0.01, col = "black", delt = 1.0, ...) } \arguments{ \item{rx }{horizontal radius of full cylinder. } \item{ry }{vertical radius of full cylinder. } \item{from }{start radius of segment, radians. } \item{to }{end radius of segment, radians. } \item{len }{cylinder length. } \item{mid }{midpoint of cylinder. } \item{angle }{rotation angle, degrees. } \item{dr }{size of segments, in radians, to draw top/bottom ellipse (decrease for smoother). } \item{col }{color of slice. } \item{delt }{increase factor, from left to right. } \item{... }{arguments passed to \link{polygon} function. } } \author{ Karline Soetaert } \examples{ emptyplot(main = "cylindersegment") cylindersegment(mid = c(0.1, 0.5), rx = 0.1, ry = 0.1, from = pi, to = 3*pi/2, col = "blue", len = 0.5, delt = 1.1, lwd = 2, angle = 90) cylindersegment(mid = c(0.8, 0.5), rx = 0.1, ry = 0.1, from = 0, to = pi/2, col = "red", len = 0.5, delt = 1.0, lwd = 2, angle = 45) cylindersegment(mid = c(0.5, 0.5), rx = 0.1, ry = 0.1, from = pi/2, to = pi, col = "lightblue", len = 0.2, delt = 1.5, lwd = 2) for (i in seq(0.1, 0.9, 0.1)) cylindersegment(mid = c(i, 0.9), rx = 0.035, ry = 0.05, from = pi/2, to = 3*pi/2, col = "darkblue", len = 0.1, angle = 90) } \details{ When \code{angle} = 0 (the default), the cylindersegment is parallel to the x-axis. \code{rx} and \code{ry} are the horizontal and vertical radiusses of the bordering ellipses. Here "horizontal" and "vertical" denote the position BEFORE rotation if \code{delt} > 1, the width of the cylinder will increase from left to right. } \seealso{ \code{\link{filledcylinder}} } \keyword{aplot} shape/man/Arrowhead.Rd0000644000176200001440000000563513432462354014347 0ustar liggesusers\name{Arrowhead} \alias{Arrowhead} \title{adds arrowheads to a plot} \description{ adds one or more arrowheads to a plot; shape is either curved, a triangle, a circle or ellipse. } \usage{ Arrowhead(x0, y0, angle = 0, arr.length = 0.4, arr.width = arr.length/2, arr.adj = 0.5, arr.type = "curved", lcol = "black", lty = 1, arr.col = lcol, arr.lwd = 2, npoint = 5, ...) } \arguments{ \item{x0 }{x-coordinates of points at which to draw arrowhead; either one value or a vector. } \item{y0 }{y-coordinates of points at which to draw arrowhead; either one value or a vector. } \item{angle }{angle of arrowhead (anti-clockwise, relative to x-axis), in degrees [0,360]; either one value or a vector. } \item{arr.length }{approximate length of arrowhead, in cm; either one value or a vector. } \item{arr.width }{approximate width of arrowhead, in cm; either one value or a vector. } \item{arr.adj }{0,0.5,1 specifying the adjustment of the arrowhead. } \item{arr.type }{type of arrowhead to draw, one of "curved", "triangle", "circle", "ellipse". } \item{lcol }{line color specifications; either one value or a vector. } \item{lty }{line type specifications; either one value or a vector. } \item{arr.col }{color of arrowhead; either one value or a vector. } \item{arr.lwd }{line width of arrowhead. } \item{npoint }{only if \code{arr.type} = "curved": number of points to draw the curve; increase for smoother arrowheads} \item{... }{arguments passed to the \code{polygon} function. }} \author{ Karline Soetaert } \examples{ emptyplot(main = "Arrowhead") Arrowhead(x0 = runif(10), y0 = runif(10), angle = runif(10)*360, arr.length = 0.3, arr.type = "circle", arr.col = "green") Arrowhead(x0 = runif(10), y0 = runif(10), angle = runif(10)*360, arr.length = 0.4, arr.type = "curved", arr.col = "red") Arrowhead(x0 = runif(10), y0 = runif(10), angle = runif(10)*360, arr.length = runif(10), arr.type = "triangle", arr.col = rainbow(10)) } \details{ \code{x0}, \code{y0}, \code{angle}, \code{arr.length}, \code{arr.width}, \code{lcol}, \code{lty} and \code{arr.col} can be a vector, of the same length. \itemize{ \item if \code{arr.adj} = 0.5, then the centre of the arrowhead is at the point at which it is drawn. \item \code{arr.adj} = 1 causes the tip of the arrowhead to touch the point. \item \code{arr.adj} = 0 causes the base of the arrowhead to touch the point. } The type of the arrowhead is set with \code{arr.type} which can take the values: \itemize{ \item "triangle": uses filled triangle \item "curved" : draws arrowhead with curved edges \item "circle" : draws circular head (where arr.width=arr.length) \item "ellipse" : draws ellipsoid head } } \seealso{ \code{\link{Arrows}} } \keyword{aplot} shape/man/plotcircle.Rd0000644000176200001440000000255211702565470014567 0ustar liggesusers\name{plotcircle} \alias{plotcircle} \title{ adds part of a colored circle to a plot } \description{ adds (part of) a colored circle to a plot; an arrow can be drawn at a specified position } \usage{ plotcircle(r = 1, ...) } \arguments{ \item{r }{radius of circle. } \item{... }{arguments passed to function \link{plotellipse}. } } \author{ Karline Soetaert } \examples{ # symmetrical axes emptyplot(c(0, 1)) plotcircle(mid = c(0.5, 0.5), r = 0.25, from = 0, to = 3*pi/2, arrow = TRUE, arr.pos = 0.5, col = "red") # symmetrical plotellipse(mid = c(0.5, 0.5), rx = 0.2, ry = 0.2, arrow = TRUE, arr.pos = 0.5, col = "blue") #non-symmetrical axes emptyplot(c(0, 1), c(0, 2), main = "plotcircle", asp = FALSE) plotcircle(mid = c(0.5, 0.5), r = 0.25, from = 0, to = 3*pi/2, arrow = TRUE, arr.pos = 0.5, col = "red") plotellipse(mid = c(0.5, 0.5), rx = 0.25, ry = 0.25, arrow = TRUE, arr.pos = 0.5, col = "blue") } \details{ \code{plotcircle} calls \code{plotellipse}, making sure that the figure drawn effectively looks like a circle. For graphs that have both axes of equal size, the circle will be equal to the ellipse with equal rx and ry. See second example see \code{\link{plotellipse}} for details } \seealso{ \code{\link{plotellipse}} to draw ellipses } \keyword{aplot} shape/DESCRIPTION0000644000176200001440000000076314051136043013063 0ustar liggesusersPackage: shape Version: 1.4.6 Title: Functions for Plotting Graphical Shapes, Colors Author: Karline Soetaert Maintainer: Karline Soetaert Depends: R (>= 2.01) Imports: stats, graphics, grDevices Description: Functions for plotting graphical shapes such as ellipses, circles, cylinders, arrows, ... License: GPL (>= 3) NeedsCompilation: no Packaged: 2021-05-19 06:02:02 UTC; karlines Repository: CRAN Date/Publication: 2021-05-19 07:20:03 UTC shape/vignettes/0000755000176200001440000000000013726641407013374 5ustar liggesusersshape/vignettes/vignettes.bib0000644000176200001440000000557711247410710016063 0ustar liggesusers@ARTICLE{Niquil98, author = {Niquil, N and Jackson, GA and Legendre, L and Delesalle, B}, title = {Inverse model analysis of the planktonic food web of Takapoto Atoll (French Polynesia).}, journal = {Marine Ecology Progress Series}, year = {1998}, volume = {165}, pages = {17--29}, } @ARTICLE{Donali99, author = {Donali, E. and Olli, K. and Heiskanen, A.-S. and Andersen, T.}, title = {Carbon flow patterns in the planktonic food web of the Gulf of Riga, the Baltic Sea: a reconstruction by the inverse method}, journal = {Journal of Marine Systems}, volume={23}, pages={251-268}, year = {1999} } @BOOK{Soetaertbook, title = {A Practical Guide to Ecological Modelling. Using R as a Simulation Platform}, publisher = {Springer}, year = {2009}, author = {Soetaert, K and Herman, P M J}, pages = {372}, note = {ISBN 978-1-4020-8623-6}, } @BOOK{Caswell01, author = {Caswell, H}, year={2001}, title={Matrix population models: construction, analysis, and interpretation}, edition={Second edition}, publisher={Sinauer, Sunderland} } @MANUAL{R2008, title = {\proglang{R}: A Language and Environment for Statistical Computing}, author = {{R Development Core Team}}, organization = {R Foundation for Statistical Computing}, address = {Vienna, Austria}, year = {2008}, note = {{ISBN} 3-900051-07-0}, url = {http://www.R-project.org} } @inproceedings{Leisch02, author = {Friedrich Leisch}, title = {Sweave: Dynamic Generation of Statistical Reports Using Literate Data Analysis}, booktitle = {Compstat 2002 --- Proceedings in Computational Statistics}, pages = {575--580}, year = 2002, editor = {Wolfgang H{\"a}rdle and Bernd R{\"o}nz}, publisher = {Physica Verlag, Heidelberg}, note = {ISBN 3-7908-1517-9}, url = {http://www.stat.uni-muenchen.de/~leisch/Sweave} } @Manual{limSolve, title = {limSolve: Solving linear inverse models}, author = {Karline Soetaert and Van den Meersche, Karel and Dick van Oevelen}, year = {2009}, note = {R package version 1.5}, } @Manual{LIM, title = {LIM: Linear Inverse Modelling}, author = {Karline Soetaert and Dick van Oevelen}, year = {2009}, note = {R package version 1.3}, } @Manual{diagram, title = {diagram: Functions for visualising simple graphs (networks), plotting flow diagrams}, author = {Karline Soetaert}, year = {2009}, note = {R package version 1.4}, } @Manual{ecolMod, title = {ecolMod: "A practical guide to ecological modelling - using R as a simulation platform"}, author = {Karline Soetaert and Peter MJ Herman}, year = {2008}, note = {R package version 1.1}, } @Manual{shape, title = {shape: Functions for plotting graphical shapes, colors}, author = {Karline Soetaert}, year = {2009}, note = {R package version 1.2.2}, }shape/vignettes/shape.Rnw0000644000176200001440000003361311702565463015171 0ustar liggesusers\documentclass[article,nojss]{jss} \DeclareGraphicsExtensions{.pdf,.eps} %%%%%%%%%%%%%%%%%%%%%%%%%%%%%% Add-on packages and fonts \usepackage{amsmath} \usepackage{xspace} \usepackage{verbatim} \usepackage[english]{babel} %\usepackage{mathptmx} %\usepackage{helvet} \usepackage[T1]{fontenc} \usepackage[latin1]{inputenc} %%%%%%%%%%%%%%%%%%%%%%%%%%%%%% User specified LaTeX commands. \newcommand{\di}{\textbf{\textsf{diagram}}\xspace} \title{\proglang{R} Package \pkg{shape}: functions for plotting graphical shapes, colors...} \Plaintitle{R Package shape: functions for plotting graphical shapes, colors...} \Keywords{graphics, shapes, colors, R} \Plainkeywords{graphics, shapes, colors, R} \author{Karline Soetaert\\ Royal Netherlands Institute of Sea Research\\ Yerseke, The Netherlands } \Plainauthor{Karline Soetaert} \Abstract{This document describes how to use the \pkg{shape} package for plotting graphical shapes. Together with R-package \pkg{diagram} \citep{diagram} this package has been written to produce the figures of the book \citep{Soetaertbook} } %% The address of (at least) one author should be given %% in the following format: \Address{ Karline Soetaert\\ Royal Netherlands Institute of Sea Research (NIOZ)\\ 4401 NT Yerseke, Netherlands E-mail: \email{karline.soetaert@nioz.nl}\\ URL: \url{http://www.nioz.nl}\\ } %%%%%%%%%%%%%%%%%%%%%%%%%%%%%% R/Sweave specific LaTeX commands. %% need no \usepackage{Sweave} %\VignetteIndexEntry{shape: functions for plotting graphical shapes} %\VignetteKeywords{graphics, shapes, colors} %\VignettePackage{shape} %%%%%%%%%%%%%%%%%%%%%%%%%%%%%% Begin of the document \begin{document} \SweaveOpts{engine=R,eps=FALSE} \SweaveOpts{keep.source=TRUE} <>= library("shape") options(prompt = "> ") options(width=90) @ \maketitle \section{Introduction} This vignette is the Sweave application of parts of demo \code{colorshapes} in package \pkg{shape} \citep{shape}. \section{colors} Although one can find similar functions in other packages (including the R base package \citep{R2008}), \pkg{shape} includes ways to generate color schemes; \begin{itemize} \item \code{intpalette} creates transitions between several colors; \item \code{shadepalette} creates a gradient between two colors, useful for shading (see below). \item \code{drapecol} drapes colors over a \code{persp} plot; \end{itemize} by default the red-blue-yellow (matlab-type) colors are used. The code below demonstrates these functions (Figure \ref{fig:s1}) <>= par(mfrow = c(2, 2)) image(matrix(nrow = 1, ncol = 50, data = 1:50), main = "intpalette", col = intpalette(c("red", "blue", "yellow", "green", "black"), numcol = 50)) # shadepalette(n = 10, "white", "black") # image(matrix(nrow = 1, ncol = 50, data = 1:50), col = shadepalette(50, "red", "blue"), main = "shadepalette") # par(mar = c(0, 0, 0, 0)) persp(volcano, theta = 135, phi = 30, col = drapecol(volcano), main = "drapecol", border = NA) @ \begin{figure} \begin{center} <>= <> @ \end{center} \caption{Use of \code{intpalette}, \code{shadepalette} and \code{drapecol}} \label{fig:s1} \end{figure} \section{Rotating} Function \code{rotatexy} rotates graphical shapes; it can be used to generate strangely-colored shapes (Figure \ref{fig:s2}). <>= par(mfrow = c(2, 2), mar = c(3, 3, 3, 3)) # # rotating points on a line # xy <- matrix(ncol = 2, data = c(1:5, rep(1, 5))) plot(xy, xlim = c(-6, 6), ylim = c(-6, 6), type = "b", pch = 16, main = "rotatexy", col = 1) for (i in 1:5) points(rotatexy(xy, mid = c(0, 0), angle = 60*i), col = i+1, type = "b", pch = 16) points(0, 0, cex = 2, pch = 22, bg = "black") legend("topright", legend = 60*(0:5), col = 1:6, pch = 16, title = "angle") legend("topleft", legend = "midpoint", pt.bg = "black", pt.cex = 2, pch = 22, box.lty = 0) # # rotating lines.. # x <- seq(0, 2*pi, pi/20) y <- sin(x) cols <- intpalette(c("blue", "green", "yellow", "red"), n = 125) cols <- c(cols, rev(cols)) plot(x, y, type = "l", ylim = c(-3, 3), main = "rotatexy", col = cols[1], lwd = 2, xlim = c(-1, 7)) for (i in 2:250) lines(rotatexy(cbind(x, y), angle = 0.72*i), col = cols[i], lwd = 2) # # x <- seq(0, 2*pi, pi/20) y <- sin(x*2) cols <- intpalette(c("red", "yellow", "black"), n = 125) cols <- c(cols, rev(cols)) plot(x, y, type = "l", ylim = c(-4, 5), main = "rotatexy, asp = TRUE", col = cols[1], lwd = 2, xlim = c(-1, 7)) for (i in 2:250) lines(rotatexy(cbind(x, y), angle = 0.72*i, asp = TRUE), col = cols[i], lwd = 2) # # rotating points # cols <- femmecol(500) plot(x, y, xlim = c(-1, 1), ylim = c(-1, 1), main = "rotatexy", col = cols[1], type = "n") for (i in 2:500) { xy <- rotatexy(c(0, 1), angle = 0.72*i, mid = c(0, 0)) points(xy[1], xy[2], col = cols[i], pch = ".", cex = 2) } @ \begin{figure} \begin{center} <>= <> @ \end{center} \caption{Four examples of \code{rotatexy}} \label{fig:s2} \end{figure} \section{ellipses} If a suitable shading color is used, function \code{filledellipse} creates spheres, ellipses, donuts with 3-D appearance (Figure \ref{fig:s3}). <>= par(mfrow = c(2, 2), mar = c(2, 2, 2, 2)) emptyplot(c(-1, 1)) col <- c(rev(greycol(n = 30)), greycol(30)) filledellipse(rx1 = 1, rx2 = 0.5, dr = 0.1, col = col) title("filledellipse") # emptyplot(c(-1, 1), c(-1, 1)) filledellipse(col = col, dr = 0.1) title("filledellipse") # color <-gray(seq(1, 0.3, length.out = 30)) emptyplot(xlim = c(-2, 2), ylim = c(-2, 2), col = color[length(color)]) filledellipse(rx1 = 2, ry1 = 0.4, col = color, angle = 45, dr = 0.1) filledellipse(rx1 = 2, ry1 = 0.4, col = color, angle = -45, dr = 0.1) filledellipse(rx1 = 2, ry1 = 0.4, col = color, angle = 0, dr = 0.1) filledellipse(rx1 = 2, ry1 = 0.4, col = color, angle = 90, dr = 0.1) title("filledellipse") # emptyplot(main = "getellipse") col <-femmecol(90) for (i in seq(0, 180, by = 2)) lines(getellipse(0.5, 0.25, mid = c(0.5, 0.5), angle = i, dr = 0.1), type = "l", col = col[(i/2)+1], lwd = 2) @ \begin{figure} \begin{center} <>= <> @ \end{center} \caption{Use of \code{filledellipse}, and \code{getellipse}} \label{fig:s3} \end{figure} \section{Cylinders, rectangles, multigonals} The code below draws cylinders, rectangles and multigonals (Figure \ref{fig:s4}). <>= par(mfrow = c(2, 2), mar = c(2, 2, 2, 2)) # # simple cylinders emptyplot(c(-1.2, 1.2), c(-1, 1), main = "filledcylinder") col <- c(rev(greycol(n = 20)), greycol(n = 20)) col2 <- shadepalette("red", "blue", n = 20) col3 <- shadepalette("yellow", "black", n = 20) filledcylinder(rx = 0., ry = 0.2, len = 0.25, angle = 0, col = col, mid = c(-1, 0), dr = 0.1) filledcylinder(rx = 0.0, ry = 0.2, angle = 90, col = col, mid = c(-0.5, 0), dr = 0.1) filledcylinder(rx = 0.1, ry = 0.2, angle = 90, col = c(col2, rev(col2)), mid = c(0.45, 0), topcol = col2[10], dr = 0.1) filledcylinder(rx = 0.05, ry = 0.2, angle = 90, col = c(col3, rev(col3)), mid = c(0.9, 0), topcol = col3[10], dr = 0.1) filledcylinder(rx = 0.1, ry = 0.2, angle = 90, col = "white", lcol = "black", lcolint = "grey", dr = 0.1) # # more complex cylinders emptyplot(c(-1, 1), c(-1, 1), main = "filledcylinder") col <- shadepalette("blue", "black", n = 20) col2 <- shadepalette("red", "black", n = 20) col3 <- shadepalette("yellow", "black", n = 20) filledcylinder(rx = 0.025, ry = 0.2, angle = 90, col = c(col2, rev(col2)), dr = 0.1, mid = c(-0.8, 0), topcol = col2[10], delt = -1., lcol = "black") filledcylinder(rx = 0.1, ry = 0.2, angle = 00, col = c(col, rev(col)), dr = 0.1, mid = c(0.0, 0.0), topcol = col, delt = -1.2, lcol = "black") filledcylinder(rx = 0.075, ry = 0.2, angle = 90, col = c(col3, rev(col3)), dr = 0.1, mid = c(0.8, 0), topcol = col3[10], delt = 0.0, lcol = "black") # # rectangles color <- shadepalette(grey(0.3), "blue", n = 20) emptyplot(c(-1, 1), main = "filledrectangle") filledrectangle(wx = 0.5, wy = 0.5, col = color, mid = c(0, 0), angle = 0) filledrectangle(wx = 0.5, wy = 0.5, col = color, mid = c(0.5, 0.5), angle = 90) filledrectangle(wx = 0.5, wy = 0.5, col = color, mid = c(-0.5, -0.5), angle = -90) filledrectangle(wx = 0.5, wy = 0.5, col = color, mid = c(0.5, -0.5), angle = 180) filledrectangle(wx = 0.5, wy = 0.5, col = color, mid = c(-0.5, 0.5), angle = 270) # # multigonal color <- shadepalette(grey(0.3), "blue", n = 20) emptyplot(c(-1, 1)) filledmultigonal(rx = 0.25, ry = 0.25, col = shadepalette(grey(0.3), "blue", n = 20), nr = 3, mid = c(0, 0), angle = 0) filledmultigonal(rx = 0.25, ry = 0.25, col = shadepalette(grey(0.3), "darkgreen", n = 20), nr = 4, mid = c(0.5, 0.5), angle = 90) filledmultigonal(rx = 0.25, ry = 0.25, col = shadepalette(grey(0.3), "orange", n = 20), nr = 5, mid = c(-0.5, -0.5), angle = -90) filledmultigonal(rx = 0.25, ry = 0.25, col = "black", nr = 6, mid = c(0.5, -0.5), angle = 180) filledmultigonal(rx = 0.25, ry = 0.25, col = "white", lcol = "black", nr = 7, mid = c(-0.5, 0.5), angle = 270) title("filledmultigonal") @ \begin{figure} \begin{center} <