[R] How to plot several graphs in a single 2D figure?
Ott Toomet
otoomet at econ.dk
Fri Apr 11 07:13:39 CEST 2003
Hi,
you are definitely looking for functions like points() and lines().
E.g. do
plot(x)
lines(y)
lines() uses the previous coordinate system (defined by plot()) and
does not draw any axes. Of course, x and y should have rougly the
same range (consider also plot(x, xlim=..., ylim=...). If the scales
are very different, you should rescale e.g. y and draw a new axis
(look ?axis).
Perhaps it helps.
Ott
 From: "Feng Zhang" <f0z6305 at labs.tamu.edu>
 Date: Thu, 10 Apr 2003 15:03:24 0500

 Thanks, Iyue

 But here the data1 and data2 are not necessarily two vectors.
 Maybe they are results from some other functions, defined
 as a data structure.
 Like using norMix package,

 x < norMix(mu=c(1,0,1.5),sig2=c(.49,.36,.16),w=c(.4,.3,.3));
 plot(x); %% x is not a vector, but a structure
 y < norMix(mu=c(2,0,2),sig2=c(.16,.36,.64),w=c(.4,.3,.3));
 par(new=T);
 plot(y);

 The result graph is messed up and x,y dont have consistent axis label
 settings.

 Fred
More information about the Rhelp
mailing list