require(icp) require(grDevices) # because xy.coords is overwritten beplot.icp <- icustom.plot( name='beplot.icp', construct=function(width, height) { ### `data` is a list with an element for each ### variable; recreate a data.frame: x <- as.data.frame(data) nalgs <- ncol(x) algs <- colnames(x) # Medals table (see table.bench): ranks <- t(apply(x, 1, as.ranking, ties='random', sorted=FALSE)) nranks <- apply(ranks, 2, function(y)table(factor(y, levels=1:nalgs))) # Simple rank based global algorithm order # (see as.ranking.medalstable): barranks <- rank(colSums(x * (nalgs:1)/nalgs), ties='random') barorder <- order(barranks) ### Plot: dotplotborders <- (0:nalgs) * nalgs dotplaces <- (1:nalgs) - 0.5 names(dotplaces) <- names(barranks)[barorder] col <- 3:(nalgs+2) names(col) <- algs #print(col) dotcols <- col ## Draw it: iaxis.reset.all() # Figure 1: xaxis.dp <- iaxis('cont', 'x', range(dotplotborders), c(30, width-30)) yaxis.dp <- iaxis('cont', 'y', c(0, max(x)), c(height-30, 30)) # Podium place borders: sobj.reset() for ( b in dotplotborders ) iabline(v=b) # Lines: #if ( lines.show ) { #if ( FALSE ) { for ( i in 1:nrow(x) ) { r <- ranks[i,] o <- order(r) performances <- (x[i,])[o] places <- (dotplaces[names(r)] + ((r - 1) * nalgs))[o] sobj.polygon(i, xaxis.dp(places), yaxis.dp(performances), closed=FALSE, fill=FALSE) } #} # Points: #if ( FALSE ) { for ( i in 1:nrow(x) ) { r <- ranks[i,] o <- order(r) performances <- (x[i,])[o] places <- (dotplaces[names(r)] + ((r - 1) * nalgs))[o] for ( j in seq_len(nalgs) ) sobj.point(i, xaxis.dp(places[j]), yaxis.dp(performances[j]), col=jcol(dotcols[o][j]), diam=7) }#} })