s-news
[Top] [All Lists]

Re: Overlaying Graphs - this one actually works

To: s-news@lists.biostat.wustl.edu
Subject: Re: Overlaying Graphs - this one actually works
From: "Andrew White" <andrew_white@hmsa.com>
Date: Wed, 31 Aug 2005 09:48:15 -1000
Thread-index: AcWtZVgMQXB0kM18RaWXtwDqLJFnXwA/tE5w
Thread-topic: [S] Overlaying Graphs - this one actually works
The previously suggested ways don't work well (ar at all) in S-Plus
Windows v6 (have not tried v7)
The following code does work  - and has the advantage of differentiating
the plots by color
Especially if the data were to be overlaid in X-Y space (as the 2 data
sets presented are not);
(The color choices can be altered to suit.)

x1 <- 1:10
x2<- 11:20
y1<- rnorm(10)
y2 <- rnorm(10,0,1.5)
plot(x1, y1, xlim = range(x1, x2), ylim = range(y1, y2), type="n") 
lines(x1, y1, type = "b", col=2)
lines(x2,y2, type="b", col=3)

Procedure Rationale:
FIRST plot the "frame" and axes but no data points content, using 'type
= "n" '
THEN plot the data point content using the lines() function, one for
x1,y1 with 1st color choice
The second with x2,y2 with 2nd color choice.

Hope this clarifies what looked rather muddy. 


Andy White
Andrew N. White, Ph.D.
Manager Research Unit
Financial Reporting, Analysis & Medical Economics Dept.
Hawaii Medical Service Association
Blue Cross Blue Shield of Hawaii
An Independent Licensee of the Blue Cross and Blue Shield Association
818 Keeaumoku Street, Honolulu, HI 96814
Ph. 808-948-5344 - Email: andrew_white@hmsa.com
<mailto:andrew_white@hmsa.com>

This electronic message is intended only for the individual or entity to
which it is addressed and may contain information that is confidential
and protected by law.  If you are not the intended recipient of this
e-mail, you are cautioned that use of its contents in any way is
prohibited and may be unlawful.  If you have received this communication
in error, please notify the sender immediately by e-mail or telephone
and return the original message by e-mail to the sender or to
postmaster@hmsa.com.  We will reimburse you for any cost you incur in
notifying us of the errant e-mail.  Thank you.



-----Original Message-----
From: s-news-owner@lists.biostat.wustl.edu
[mailto:s-news-owner@lists.biostat.wustl.edu] On Behalf Of Sundar
Dorai-Raj
Sent: Tuesday, August 30, 2005 3:18 AM
To: TzamouranisY@LouisDreyfus.com
Cc: Khan, Sohail; s-news@lists.biostat.wustl.edu
Subject: Re: [S] Overlaying Graphs


I think the preferred way of doing this is:

x1 <- 1:10
x2<- 11:20
y1<- rnorm(10)
y2 <- rnorm(10,0,1.5)
plot(x1, y1, xlim = range(x1, x2), ylim = range(y1, y2), type="b")
lines(x2, y2, type = "b")


--sundar

TzamouranisY@LouisDreyfus.com wrote:
> 
> Try this, Sohail:
>  x1 <- 1:10
>  > x2<- 11:20
>  > y1<- rnorm(10)
>  > y2<-rnorm(10,0,1.5)
>  > plot(x1,y1, xlim=range(x1,x2) , ylim=range(y1,y2) , type="b")  > 
> par(new=T, xaxs="d")  > plot(x2,y2, xlim=range(x1,x2), type="b" )
> 
> Yannis Tzamouranis
> 
> 
>       *"Khan, Sohail" <khan@cshl.edu>*
> Sent by: s-news-owner@lists.biostat.wustl.edu
> 
> 08/29/2005 05:11 PM
> 
>              
>         To:        <s-news@lists.biostat.wustl.edu>
>         cc:        
>         Subject:        [S] Overlaying Graphs
> 
> 
> 
> 
> 
> Dear S-PLUS users,
> I want to create overlaying scatter plots.  I.E. I have common x-axis
> for multiple variables.
> I couldn't find info. on how to go about doing this in the s-plus 
> manual.  I apologize if this is a trivial question for this list.
> Thanks
> 
> 
> Sohail Khan
> Scientific Programmer
> COLD SPRING HARBOR LABORATORY
> Genome Research Center
> 500 Sunnyside Boulevard
> Woodbury, NY 11797
> (516)422-4076
> 
> --------------------------------------------------------------------
> This message was distributed by s-news@lists.biostat.wustl.edu.  To 
> unsubscribe send e-mail to s-news-request@lists.biostat.wustl.edu with

> the BODY of the message:  unsubscribe s-news
> 
> 
--------------------------------------------------------------------
This message was distributed by s-news@lists.biostat.wustl.edu.  To
unsubscribe send e-mail to s-news-request@lists.biostat.wustl.edu with
the BODY of the message:  unsubscribe s-news



<Prev in Thread] Current Thread [Next in Thread>
  • Re: Overlaying Graphs - this one actually works, Andrew White <=