From r-help-bounces@stat.math.ethz.ch Tue Feb  3 23:08:59 2004
Date: Tue, 03 Feb 2004 09:50:39 +0100
From: Peter Wolf <s-plus@wiwi.uni-bielefeld.de>
Subject: Re: [R] R: plotting multiple functions
To: allan clark <allan@stats.uct.ac.za>, r-help@stat.math.ethz.ch
MIME-version: 1.0
Content-type: text/plain; charset=us-ascii; format=flowed
Content-transfer-encoding: 7BIT
X-Accept-Language: en-us, en
User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.0.1) Gecko/20020903
X-Enigmail-Version: 0.63.3.0
X-Enigmail-Supports: pgp-inline, pgp-mime
X-Spam-Checker-Version: SpamAssassin 2.63 (2004-01-11) on hypatia.math.ethz.ch
X-Spam-Status: No, hits=-2.4 required=5.0 tests=AWL,
	BAYES_44 autolearn=no version=2.63
X-Spam-Level: 
Cc: 
X-BeenThere: r-help@stat.math.ethz.ch
X-Mailman-Version: 2.1.4
List-Id: "Main R Mailing List: Primary help" <r-help.stat.math.ethz.ch>
List-Unsubscribe: <https://www.stat.math.ethz.ch/mailman/listinfo/r-help>,
	<mailto:r-help-request@stat.math.ethz.ch?subject=unsubscribe>
List-Archive: <https://www.stat.math.ethz.ch/pipermail/r-help>
List-Post: <mailto:r-help@stat.math.ethz.ch>
List-Help: <mailto:r-help-request@stat.math.ethz.ch?subject=help>
List-Subscribe: <https://www.stat.math.ethz.ch/mailman/listinfo/r-help>,
	<mailto:r-help-request@stat.math.ethz.ch?subject=subscribe>
X-MD-Debug: -4.9 BAYES_00
X-Scanned-By: MIMEDefang 2.35
Content-Length: 1191

allan clark wrote:

>Hi all
>
>Another simple question.
>
>I would like to plot three graphs one the same plot with different
>colours. Say red, blue and black. Here are the functions.
>
>r1<-1+5*cos(2*pi*seq(1:100)/20)+rnorm(100)
>r2<-1+7*sin(2*pi*seq(1:100)/20)+rnorm(100)
>r3<-1+7*sin(2*pi*seq(1:100)/20)+5*cos(2*pi*seq(1:100)/20)+rnorm(100)
>
>Regards
>Allan
>
Try:

r1<-1+5*cos(2*pi*seq(1:100)/20)+rnorm(100)
r2<-1+7*sin(2*pi*seq(1:100)/20)+rnorm(100)
r3<-1+7*sin(2*pi*seq(1:100)/20)+5*cos(2*pi*seq(1:100)/20)+rnorm(100)

x <- 1:100
y.min<-min(r1,r2,r3)
y.max<-max(r1,r2,r3)
plot(x,type="n",main="3 graphs", xlab="x",ylab="",ylim=c(y.min,y.max))
lines(x,r1,col="red")
lines(x,r2,col="blue")
lines(x,r3,col="black")
vp<-par()$usr
legend(vp[1]+0.85*(vp[2]-vp[1]),
              vp[3]+0.9*(vp[4]-vp[3]),
              legend=c("graph1","graph2","graph3"),             
              col=c("red","blue","black"),
              lty=rep(1,3),
              bty="n")


Peter

______________________________________________
R-help@stat.math.ethz.ch mailing list
https://www.stat.math.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html

