[R] how to draw two graphs in one graph window

Rau, Roland Rau at demogr.mpg.de
Sun Aug 15 13:00:17 CEST 2004


	-----Original Message-----
	From:	r-help-bounces at stat.math.ethz.ch
[SMTP:r-help-bounces at stat.math.ethz.ch] On Behalf Of Chuanjun Zhang
	Sent:	Sunday, August 15, 2004 1:14 AM
	To:	r-help at stat.math.ethz.ch
	Subject:	[R] how to draw two graphs in one graph window

it is not really clear (at least not to me) what you mean.
a) Do you want to add two graphs into one figure?
b) Do you want to add two graphs on the same page?

The following two simple code examples might help to do what you want. 

### ad a)
x <- 1:100
plot(x=x, y=x, type="l", col="red")
lines(x=x, y=x/2, col="blue")
### ad b)
x <- 1:100
plot(x=x, y=x, type="l", col="red")
plot(x=x, y=x^2, type="l", col="blue")

Please try to be more specific in your next postings. And please read the
posting guide (see bottom of every message). It suggests to use
- help.search("keyword")
- read the online help
- check the relevant FAQs
- read at least the relevant section in "An Introduction to R" which is
shipped with every binary distribution of R.
Relevant for your question is section 12 "Graphical Procedures".
There you will find all the information you need to get started (especially
sections 12.1, 12.2, 12.4, 12.5).


This mail has been sent through the MPI for Demographic Rese...{{dropped}}

More information about the R-help mailing list