1
2##==============================================================================
3## plotellipse     : plots (part of) an ellipse
4##==============================================================================
5
6plotellipse <- function (rx=1, ry=0.2, mid=c(0,0), dr=0.01,
7  angle=0, from=-pi, to=pi, type="l", lwd=2, lcol="black",
8  col=NULL, arrow=FALSE, arr.length=0.4, arr.width=arr.length*0.5,
9  arr.type="curved", arr.pos=1, arr.code=2, arr.adj=0.5,
10  arr.col="black",  ...) {
11
12
13  xy<-getellipse (rx,ry,mid,angle=angle,dr=dr,from=from,to=to)
14
15  if (! is.null(col))
16    polygon(xy,col=col,border=NA)
17  if (type != "n" )
18    lines(xy,type=type,lwd=lwd,col=lcol,...)
19  nr <- nrow(xy)
20
21  if (arrow) {
22    ilen <- length(arr.pos)
23    if (ilen>1) {
24      arr.code  <- rep(arr.code  ,length.out=ilen)
25      arr.col   <- rep(arr.col   ,length.out=ilen)
26      arr.length<- rep(arr.length,length.out=ilen)
27      arr.width <- rep(arr.width ,length.out=ilen)
28      arr.type  <- rep(arr.type  ,length.out=ilen)
29      arr.adj   <- rep(arr.adj   ,length.out=ilen)
30    }
31
32    for (i in 1: ilen) {
33      ii <- max(2,trunc(nr*arr.pos[i]))
34      Arrows(xy[ii-1,1], xy[ii-1,2], xy[ii,1], xy[ii,2],
35            lcol=arr.col[i], code=arr.code[i], arr.col=arr.col[i],
36            arr.length =arr.length[i], arr.width=arr.width[i],
37            arr.type=arr.type[i], arr.adj=arr.adj[i])
38    }
39  }
40}
41