maybe this q&d try helps?


#=================cut herer=============

vectorplot <- function (field) {

  #input is a (N x 4 array) of N vectors:
  #   field[,1:2] - x/y position  of vectors
  #   field[,3:4] - x/y componnent of vectors
  # plotted are the 2-D vectors attached to  the specified positions

  if (is.null(dim(field))||dim(field)[2] != 4) stop("N x 4 array expected")

  loc <- field[,1:2]
  val <- field[,3:4]

  alpha <- rbind(loc[,1],loc[,1]+val[,1])
  omega <- rbind(loc[,2],loc[,2]+val[,2])

  matplot(alpha,omega,type='l',lty=1,col='black') #the vector lines
  points(loc) #the start points
  points(loc+val,pch=20) #the end points
}

#example:

loc=matrix(rnorm(100),50,2)
field <- cbind(loc,loc)
vectorplot(field)

#=================cut herer=============

there are no nice arrow heads, of course, but one could construct some...
for now, vectors start with open circles and end with filled circles.

joerg

______________________________________________
[EMAIL PROTECTED] mailing list
https://www.stat.math.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html

Reply via email to