Subversion Repositories bdplot

Rev

Rev 57 | Go to most recent revision | Blame | Compare with Previous | Last modification | View Log | RSS feed

### a function to plot all columns in a matrix

bdmatplot <- function(x,y=NULL,cols=NULL,ltys=NULL,...){
##  browser()
  
  if(is.null(y)){
    y <- as.matrix(x)
    dim.y <- dim(y)
    x <- 1:dim.y[1]
  } else {
    y <- as.matrix(y)
    dim.y <- dim(y)
  }
  ## if(is.null(dim(y))){
  ##   dim.y <- c(length(y),1)
  ## }
##  print(dim.y)

  if(is.null(cols))
    cols <- 2:(dim.y[2]+1)

  if(is.null(ltys))
    ltys <- rep(1,dim.y[2])
  ##  print(cols)

  
  bdplot(x,y[,1],ylim=range(y,na.rm=TRUE),col=cols[1],lty=ltys[1],...)

  if(dim.y[2]>1){
    
    for (i in 2:dim.y[2]){
      bdpoints(x,y[,i],col=cols[i],lty=ltys[i],...)
    }

  }

}

## for backward compatibility
bdplotmat <- bdmatplot