Override R-trellis parallel chart auto.key

I used the parallel array trellis packet method to build data and ran into the problem of generating a legend. I created a vector of custom colors for the plot, but I could not find a way to convey them in order to override the default colors specified in the legend. Although I did not have enough time and ended up correcting the colors of the legends in Photoshop, I would like to know the correct way to do this in the grid.

Here is the code that generated the chart with a 4-column legend:

parallelplot(acc, horizontal.axis=FALSE, col=acc_colors, lwd=1.5, cex=2.5, ylab="Accuracy (Min = 50%, Max = 100%)", xlab="Activity (overall = average across activities)", main="Human Activity Recognition Accuracy", scales=list(cex=1), auto.key=list(text=c("Test Set", "Test Subject", "Training Set", "Training Subject"), title=" ", space="top", columns=4, points=FALSE) ) 

Any ideas on how to convey custom legend colors?

+4
source share
1 answer

Using show.settings () and str (trellis.par.get ()) showed that the graphic parameter that needs to be configured is superpose.line. Using the par.settings parameters for transmission in user settings gave custom key colors and line widths when using auto.key:

 acc_par <- list(superpose.line = list(col = key_colors), lwd=1.5, lty=1.5) parallelplot(acc, horizontal.axis=FALSE, col=acc_colors, lwd=1.5, cex=2.5, ylab="Accuracy (Min = 50%, Max = 100%)", xlab="Activity (overall = average across activities)", main="Human Activity Recognition Accuracy", scales=list(cex=1), par.settings=acc_par, auto.key=list(text=c("Test Set", "Test Subject", "Training Set", "Training Subject"), title=" ", space="top", columns=4, lines=TRUE) ) } 

This article has been helpful in finding this solution.

+6
source

All Articles