[R] Log scale on y axis of parallel coordinate plot (lattice)

Roland Seubert rseubert at ymail.com
Mon Jan 7 12:21:08 CET 2013

Hello all,

I would like to make a parallel coordinate plot with lattice. The plot 
should have vertical log scale axes, and should in principle look like 
this one (I put less chemical elements in my example below):


The data I am trying to plot are chemical analyses of rock samples (data 
frame "df"). The data needs to be normalised against a reference sample 
(vector "norm"), to get the actual data to be plotted (data frame 
"df_n"). Here is a simplified example:

 > df <- data.frame(La = c(3.0, 2.9, 2.7), Eu = c(0.86, 0.76, 0.66), Lu 
= c(0.07, 0.04, 0.04), row.names = c("sample1", "sample2", "sample3"))
 > norm <- c(0.237, 0.0563, 0.0246)
 > df_n <- df / norm
 > df_n
                La        Eu        Lu
sample1  12.65823  3.628692 0.2953586
sample2  51.50977 13.499112 0.7104796
sample3 109.75610 26.829268 1.6260163

The plot needs the same scale for all axes, so my simple panel function 
would be:

 > panel.myplot <- function(..., common.scale) {panel.parallel(..., 
common.scale = TRUE)}

I tried to plot the data with the following command to get vertical axes 
with a log scale:

 > parallelplot(~ df_n, panel = panel.myplot, horizontal.axis = FALSE, 
scales = list(y = list(log = 10)))

The problem is that lattice simply ignores the log scale and gives me 
the following warning:

Warning message:
In parallelplot.formula(~df_n, panel = panel.spiderplot, horizontal.axis 
= FALSE,  :
   cannot have log y-scale

I browsed through the source code of the respective lattice source file 
and it seems to me that lattice does not support a log scale for y axes 
in parallel coordinate plots? I would greatly appreciate if anyone had 
an idea how to make this plot with lattice or point me to some kind of 

Thanks a lot in advance,


More information about the R-help mailing list