[R] multiple xyplots on the same graph
Deepayan Sarkar
deepayan.sarkar at gmail.com
Fri Sep 29 00:33:56 CEST 2006
On 9/28/06, S. Swaminathan <sswami at hotmail.com> wrote:
> I am new to R and am having trouble plotting multiple xyplots on the same
> graph.
> I have a dataframe x1 with 3 columns month, var1, var2. Month is a factor
> while var1 and var2 are numeric.
> Reading through the archives I learned to plot var1 vs month and var2 vs
> month and have them as two plots in one window by doing the following
> library(lattice)
> x<-xyplot(var1~month,type="b")
> y<-xyplot(var2~month,type="b")
> print(x,split(c(1,1,1,2),more=TRUE)
> print(y,split(c(1,2,1,2))
>
> How do I get just one plot with month as the x axis and two lines for var1
> and var2 ?
xyplot(var1 + var2 ~ month,
data = x1,
type = "b")
Incidentally, R has a help system, and you will usually get more
reliable information if you read the help page of the function you are
using rather than "read through the archives". In this case, that
would be done by typing ?xyplot or help(xyplot).
-Deepayan
More information about the R-help
mailing list