[R] line colors in lattice.xyplot with png device
Deepayan Sarkar
deepayansarkar at vsnl.net
Sat Jul 19 00:10:59 CEST 2003
On Friday 18 July 2003 12:28, r-help-request at stat.math.ethz.ch wrote:
> Message: 9
> Date: Thu, 17 Jul 2003 13:50:29 +0200
> From: Marc Mamin <M.Mamin at intershop.de>
> Subject: [R] line colors in lattice.xyplot with png device.
> To: r-help at stat.math.ethz.ch
>
> 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()
With (simpler) simulated data:
y1 <- rnorm(50)
y2 <- rnorm(50)
x <- 1:50
xyplot(y1 + y2 ~ x, allow.m = TRUE, type = 'l',
col = c("red", "blue"))
There are more complicated ways, namely by changing the trellis parameter
superpose.line (see ?trellis.par.get and ?lset).
> another problem is that I don't get a white backgroud, which is quite
> problematic when printing the output.
> (I works on WIN2K)
Try (see ?trellis.device)
trellis.device(png, ..., bg = "white")
Also, see ?col.whitebg
> 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 ?
Not really, unless you are willing to write some complicated panel functions.
HTH,
Deepayan
More information about the R-help
mailing list