Subversion Repositories bdplot

Rev

Rev 65 | 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,xlab=bdp()$xlab,...){
##  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(cols))
    cols <- 2:(dim.y[2]+1)

  if(is.null(ltys))
    ltys <- rep(1,dim.y[2])
  
  bdplot(x,y[,1],ylim=range(y,na.rm=TRUE),col=cols[1],lty=ltys[1],xlab=xlab,...)

  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