[R] two plots in one frame

David A Richmond richmond at saintmarys.edu
Fri Nov 16 03:24:27 CET 2001


On Thu, 15 Nov 2001, Justin Fay wrote:

> I would like to plot two different scatterplots in the same frame (say with 
> different colors) but everytime plot is called a new frame is created.  Is 
> there a way around this?

if, say, you want to plot 2 sets of y's against the same x, the
following:

plot(x,y1,ylim=range(c(y1,y2)))
points(x,y2,pch=17)

makes sure that all the data from y2 are displayed in the plot. If you
don't specify the 'ylim=...' option, you won't get all the data in if some
values of y2 are outside the range of y1. pch=17 tells it to use a
different symbol (the default symbol is a circle, and pch=17 is a
triangle).

daver

+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|David Richmond                It works on a          |      
+ Dept. of Sociology          complex scientific      + 
|Saint Mary's College          principle, known as    |  
+ Notre Dame, IN 46556               "pot luck."      +
|219-284-4517                    - The Doctor         |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+


-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !)  To: r-help-request at stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._



More information about the R-help mailing list