# Re: [R] how can i superpose 2 graphs

From: Jorge Ivan Velez <jorgeivanvelez_at_gmail.com>
Date: Tue, 20 May 2008 12:53:09 -0400

Hi there,
Perhaps:

set.seed(122)
x=1:50
y1=2*x+x^2
y2=x^2

plot(x,y1,ylim=range(y1,y2),type='l',ylab=expression(f(x)),xlab='x', main='Two superimposed graphs')
points(x,y2,type='l',col=2)
legend("topleft",c(expression(f(x)==2*x+x^2),expression(f(x)==x^2)),lty=1,col=1:2)

Also you could check ?curve and ?lines.

HTH, Jorge

On Sun, May 18, 2008 at 1:18 PM, hanen <hanen.mastouri_at_yahoo.fr> wrote:

>
> Hio
>
> i tried to do this by:
> par(new=TRUE)
>
> but the result is one picture but y-axis has 2 différent graduations.how
> can
> i correct this?( i want one graduation on y axis).
> --
> View this message in context:
> http://www.nabble.com/how-can-i-superpose-2--graphs-tp17305355p17305355.html
> Sent from the R help mailing list archive at Nabble.com.
>
> ______________________________________________
> R-help_at_r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>

[[alternative HTML version deleted]]

R-help_at_r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. Received on Tue 20 May 2008 - 17:27:39 GMT

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Tue 20 May 2008 - 17:30:42 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.