# [R] How to plot two graphs on one single plot?

Clint Bowman clint at ecy.wa.gov
Fri Feb 23 16:55:12 CET 2007

```?par

try par(new=TRUE) between plots

Clint Bowman			INTERNET:	clint at ecy.wa.gov
Air Dispersion Modeler		INTERNET:	clint at math.utah.edu
Air Quality Program		VOICE:		(360) 407-6815
Department of Ecology		FAX:		(360) 407-7534

USPS:  		PO Box 47600, Olympia, WA 98504-7600
Parcels:	300 Desmond Drive, Lacey, WA 98503-1274

On Fri, 23 Feb 2007, Yun Zhang wrote:

> Thanks. Now R plots two graphs on one plot.
> Yet they are still on two graphs, vertically parallelized with each other.
>
> But what I want to do is actually plotting two distribution on one
> single graph, using the same x and y axis. Like:
> |
> |
> |               (dist2)
> |   (dist 1)
> |
> --------------------------->
>
> Is it possible to do that?
>
> Thanks,
> Yun
>
> Henrique Dallazuanna wrote:
> > par(mfrow=c(2,1))
> > #after plot
> > par(mfrow=c(1,1))
> >
> > On 23/02/07, *Yun Zhang* <yunzhang at princeton.edu
> > <mailto:yunzhang at princeton.edu>> wrote:
> >
> >     Hi,
> >
> >     I am trying to plot two distribution graph on one plot. But I dont
> >     know
> >     how. I set them to the same x, y limit, even same x, y labels.
> >
> >     Code:
> >     x1=rnorm(25, mean=0, sd=1)
> >     y1=dnorm(x1, mean=0, sd=1)
> >
> >     x2=rnorm(25, mean=0, sd=1)
> >     y2=dnorm(x2, mean=0, sd=1)
> >     plot(x1, y1, type='p', xlim=range(x1,x2), ylim=range(y1, y2),
> >     xlab='x',
> >     ylab='y')
> >     plot(x2, y2, type='p', col="red", xlab='x', ylab='y')
> >
> >     They just dont show up in one plot.
> >
> >     Any hint will be very helpful.
> >
> >     Thanks,
> >     Yun
> >
> >     ______________________________________________
> >     R-help at stat.math.ethz.ch <mailto:R-help at stat.math.ethz.ch> mailing
> >     list
> >     https://stat.ethz.ch/mailman/listinfo/r-help
> >     <https://stat.ethz.ch/mailman/listinfo/r-help>
> >     http://www.R-project.org/posting-guide.html
> >     and provide commented, minimal, self-contained, reproducible code.
> >
> >
> >
> >
> > --
> > Henrique Dallazuanna
> > Curitiba-Paraná
> > Brasil
>
> ______________________________________________
> R-help at stat.math.ethz.ch mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help