[R] Plotting functions on the same figure

Peter Dalgaard p.dalgaard at biostat.ku.dk
Sat May 21 15:19:26 CEST 2005


Volkan Kumbasar <volkan.kumbasar at linux-sevenler.org> writes:

> Hi there,
> i am a newbie :P
> 
> My simple question is:
> Is there command which is equal of the m*tl*abs `hold on` command.
> In other words i want to plot 5 functions in the same figure.

I wouldn't know exactly what `hold on` does. If you are plotting
functions using curve(), notice that you can set add=TRUE (but you do
have to get the xlim and ylim right on the first graph).

Otherwise, matplot() with type="l" could be the ticket. Or plot()
followed by lines().

The most drastic measure - and usually the wrong idea - is to set
par(plot.new=TRUE) to make the next plot believe that it doesn't need
to clear the screen (or advance the page as the case may be).
Obviously, you need to careful that the axes and titles are the same,
or suffer the consequences...

-- 
   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