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

Patrick Connolly p_connolly at slingshot.co.nz
Wed Jan 16 20:05:37 CET 2013


On Mon, 07-Jan-2013 at 10:21PM +1100, Roland Seubert wrote:

|> 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):
|> 
|> http://www.geokem.com/images/scans/epr-and-N_Chile_Ridge.gif
|> 
|> 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

Check out how to use the scales list in the help for xyplot().  You
might need to brush up on how the help for axis() to see which
parameters you need to set.

HTH

-- 
~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.   
   ___    Patrick Connolly   
 {~._.~}                   Great minds discuss ideas    
 _( Y )_  	         Average minds discuss events 
(:_~*~_:)                  Small minds discuss people  
 (_)-(_)  	                      ..... Eleanor Roosevelt
	  
~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.



More information about the R-help mailing list