Example of Overlaying Lines and Curves

If you want to understand better how to overlay lines, try the following tutorial.
To see the final product, click on graph. But it would be best to
copy the commands over to your screen and execute them yourself.

1) First create some data:

Slab> rnorm(10)->x
Slab> rnorm(10)->y

2) Set up plotting two graphs per page and get scatterplot.

Slab> set.panel(2,1)
Slab> plot(x,y)

3) Create a grid of x values with the same range a
s x (but with more points).

Slab> seq(min(x),max(x),,50)->xnew

4) Create the y's that go with a line having
intercept=-1 and slope=1.4.

Slab> -1+1.4*xnew->y1

5) Now overlay this line.
(Remember that lines only adds to an existing plot.)
And don't be upset if you get a warning about
Lines out of Bounds. That just means your y's
are outside of the graphing area defined by [min(y),max(y)].

Slab> lines(xnew,y1)

6) Create the y's that go with a line having
intercept=-1 and slope=-0.8.

Slab> -1-0.8*xnew->y2

7) Overlay this new line.

Slab> lines(xnew,y2)

8) Now we will do the same thing but with two
quadratic functions (f(x)=-2+2x^2 and f(x)=-1+2x^2).

Slab> plot(x,y)
Slab> -2+xnew+2*xnew*xnew->y3
Slab> lines(xnew,y3)
Slab> -1+xnew+2*xnew*xnew->y4
Slab> lines(xnew,y4)

To see the final product, click on graph.