[R] customizing the color and point shape for each line drawn using lattice's xyplot

Gen gingerlygen at gmail.com
Sat Sep 1 00:12:05 CEST 2007


I have succeeded in controlling the line colors and point symbols of each
Method plotted in each frame of my xyplot, using the help files you
suggested so that some methods can be represented by the same color and
distinguished by symbols using the following code (I can not, however, seem
to make the key reflect these color and symbol changes):

#assign colors to each method
lcol <- rep(0, 243)
lcol[common$Method==1] <- 1 
lcol[common$Method==2] <- 2
lcol[common$Method==3] <- 3
lcol[common$Method==4] <- 6
lcol[common$Method==5] <- 4
lcol[common$Method==6] <- 4
lcol[common$Method==7] <- 5
lcol[common$Method==8] <- 5  
lcol[common$Method==9] <- 6 

#assign the type of symbol that corresponds to each method
ptype <- rep(0, 243)
ptype[common$Method==1] <- NA 
ptype[common$Method==2] <- NA
ptype[common$Method==3] <- NA
ptype[common$Method==4] <- 3
ptype[common$Method==5] <- 6
ptype[common$Method==6] <- 2
ptype[common$Method==7] <- NA
ptype[common$Method==8] <- NA  
ptype[common$Method==9] <- NA 

xyplot(Yvar~ Xvar| Avar * Bvar, data=common.without.Method478,
groups=method.not478.f, type="o", col=lcol, pch=ptype, cex=0.5,
auto.key=list
(text=c("Method 1","Method 2","Method 3","Method 4a","Method 4b","Method
9"), points = TRUE, lines = TRUE, col=c(1,2,3,4,4,6), cex=1,
pch=c(NA,NA,NA,6,2,NA)))
	
The above code obtains the desired plot, and is the closest that I have come
to obtaining the desired key.  Using the above code, within the key, I
obtain the appropriate text and the text is colored such that the text
"Method 1" corresponds to the color of method 1 in the plot. The symbol
shape and line color to the right of this text, however, does not change
from its default settings, and therefore does not reflect the plot.  I am
trying to obtain black text with appropriate symbols and appropriately
colored lines to the right. 

Have I misinterpreted the syntax of the atuo.key function?

- Genevieve

-- 
View this message in context: http://www.nabble.com/customizing-the-color-and-point-shape-for-each-line-drawn-using-lattice%27s-xyplot-tf4351934.html#a12434887
Sent from the R help mailing list archive at Nabble.com.



More information about the R-help mailing list