[R] How to plot several graphs in a single 2-D figure?
Peter Dalgaard BSA
p.dalgaard at biostat.ku.dk
Thu Apr 10 22:15:29 CEST 2003
"Feng Zhang" <f0z6305 at labs.tamu.edu> writes:
> Hi, R-listers
>
> I tried to plot several graphs in a sigle x-y coordinate settings, like the
> following:
> |(y) s
> | ****** s
> | ***** s
> | sssssssssssssssssss
> |_______________________________(x)
> where "*" and "s" denote two diffrent plots.
>
> However, when I used
> plot(data1); % data1 is the data points of "*"
> par(new=T);
> plot(data2); % data2 is the data points of "s"
>
> I found that the x and y labels are messed up, since different graphs use
> diffrent unit length on the x-axis and y-axis.
>
> So is there someway to avoid this problem?
> Or is there some other function plottting multiple plots in
> one x-y axis setting?
There are several. I assume data1 and data2 are data frames with an x
and a y column? Then you might do
plot(rbind(data1,data2),type="n")
points(data1,pch=1)
points(data2,pch=2)
Another way is to do what you already did, but add explicit xlim and
ylim arguments.
--
O__ ---- Peter Dalgaard Blegdamsvej 3
c/ /'_ --- Dept. of Biostatistics 2200 Cph. N
(*) \(*) -- University of Copenhagen Denmark Ph: (+45) 35327918
~~~~~~~~~~ - (p.dalgaard at biostat.ku.dk) FAX: (+45) 35327907
More information about the R-help
mailing list