[R] xyplot: Plotting two variables, one as points - the other as line. Can that be done without explicitly using panel functions
Deepayan Sarkar
deepayan.sarkar at gmail.com
Wed Nov 1 18:41:01 CET 2006
On 11/1/06, Søren Højsgaard <Soren.Hojsgaard at agrsci.dk> wrote:
> Hi! Consider
> d <- data.frame(x=1:10,y=5+1:10, yf=rnorm(10,5+1:10))
> x y yf
> 1 1 6 5.268621
> 2 2 7 8.623896
> 3 3 8 8.114830
> 4 4 9 10.125955
> 5 5 10 9.977261
> ...
>
> I plot y and yf against x with
>
> xyplot(y+yf~x,data=d,col=c('red','green'),pch=c("a","b"))
>
> BUT - I would like that the plot of y against x is with type='l' and the plot of yf against x is with type='p'.
>
> 1) Can this be done easily (i.e. without panel functions)? (Doing
>
> xyplot(y+yf~x,data=d,type=c("l","p"),col=c('red','green'),pch=c("a","b"))
>
> is not the way ahead)
xyplot(y+yf~x,data=d,type=c("l","p"),col=c('red','green'),
pch=c("a","b"),
distribute.type = TRUE)
> 2) How to do it with panel functions?
See ?panel.superpose
-Deepayan
More information about the R-help
mailing list