# File: vparallel.fun # Programmer: Dan Carr # Date: August 20, 1995 # Purpose: A single page vertical axis parallel coordinate plot # Integer values for highlight + 1 give the color numbers # Could bring out the lwd parameter, currently 3 for # highlight greater than 1 pcoord <- function(mat,nam=paste("x",(1:ncol(mat)),sep=""), highlight=rep(1,nrow(mat)), col=rep(1,nrow(mat)), dx=.2,xcex=1, ignorelast=0, scale=T, xlab=" ", ylab=" ",main=" ", ycex=1,mcex=1,mai=c(1.5,1.5,1.2,1.2)){ # general set up_________________________________________________________ if(scale){ # scale each column of mat to between 0 and 1 mn <- apply(mat,2,min) mx <- apply(mat,2,max) mat <- t((t(mat)-mn)/(mx-mn)) } ry <- range(mat) nc <- ncol(mat) rx <- c(1-dx,nc+dx) nr <- nrow(mat) par(xaxs='i',mai=mai) plot(rx,ry,type='n',axes=F,xlab='',ylab='',main='',cex=mcex) axis(side=1,at=1:nc,labels=nam,cex=xcex) axis(side=2,cex=ycex) mtext(xlab,side=1,line=3.5,cex=xcex) mtext(ylab,side=2,line=3.5,cex=ycex) mtext(main,side=3,line=1,cex=mcex) box() for (j in 1:max(highlight)){ good <- highlight==j if(any(good)){ n <- sum(good) lwd <- ifelse(j>1,3,1) #par(col=j+1) if(ignorelast>0){ for (i in 1:(nc-2)){ segments(rep(i,n),mat[good,i],rep(i+1,n),mat[good,i+1],lwd=lwd, col=col[good]) } last <- good last[1:(nr-ignorelast)] <- F segments(rep(nc-1,n),mat[last,nc-1],rep(nc,n),mat[last,nc],lwd=lwd, col=col[last]) } else { for (i in 1:(nc-1)){ segments(rep(i,n),mat[good,i],rep(i+1,n),mat[good,i+1],lwd=lwd, col=col[good]) } } } } par(col=1) for (i in 1:nc)abline(v=i,lwd=1) box() }