Hi, R is very new for me, so excuse if my questions are too basic... BTW, are there any forum where new R users could get help without annoying this huge mailing list ? In following code, I'd like to choose the color for each of the curve diplayed. png(filename = filename, width = 950, height = 600, pointsize = 10, bg "white") xyplot(HITS+MS1*3+FREQ~TIME |SERVER*LOCAL, data=myd,allow.multiple = TRUE, scales = "same", type="l") dev.off() another problem is that I don't get a white backgroud, which is quite problematic when printing the output. (I works on WIN2K) and last but not least, is there a way to use 2 different y axis, i.e. curve 1& 2 => left axis, curve 3 => right axis ? Sample codes would be welcome as I'm not yet used with the R syntax Thanks, Marc Mamin
for the background try:
# open a trellis device. If not open the next step will not work
trellis.device(device=windows) #x11 in linux
# set background to white. Only works on an open trellis device
background<-trellis.par.get("background")
background$col<-"white"
trellis.par.set("background",background)
# set the default line colour to black
plot.line<-trellis.par.get("plot.line")
plot.line$col<-"black"
trellis.par.set("plot.line",plot.line)
# set the default symbol colour to black
dot.symbol<-trellis.par.get("dot.symbol")
dot.symbol$col<-"black"
trellis.par.set("dot.symbol",dot.symbol)
# set strip background color
strip.background<-trellis.par.get("strip.background")
strip.background$col<-"white"
trellis.par.set("strip.background",strip.background)
should be self explanatory
try ?par to get na idea on how to get different colours for the line. the
lattice/trellis manual is avalable in pdf from bell labs
FC
========================
Federico C.F. Calboli
Department of Biology
University College London
Room 327
Darwin Building
Gower Street
London
WClE 6BT
Tel: (+44) 020 7679 4395
Fax (+44) 020 7679 7096
f.calboli at ucl.ac.uk
here is the solution:
col<-c("#cc0000", "#330099",
"#66cc00","#ff6600" ,"#ff00cc",
"#00000",
"#bo7080", "#7080bo")
lty<-c(1,1,1,1,1,1,1,1)
lwd<-c(1,1,1,1,1,1,1,1)
mylines<-list(col=col,lty=lty,lwd=lwd)
filename<- "c:\\temp\\test.png"
trellis.device(png,filename = filename, width = 940, height = 600, pointsize
= 10, bg = "white")
trellis.par.set("superpose.line",mylines)
xyplot(HITS+FREQ~TIME |SERVER*LOCAL, data=subset(myd,
TYPE=="xxx"),allow.multiple = TRUE, scales = "same",
type="l",xlim=range(myd$TIME), ylim=c(0,80000),layout=c(3,2),
key = list(lines = Rows(trellis.par.get("superpose.line"),
c(1:2)),
text = list(lab=c("total hits", "hits per day")),
columns = 2),
dev.off()
Thanks to Andy Liaw and Federico C.F. Calboli
Marc Mamin