# [R] Plotting a quadratic line on top of an xy scatterplot

From: Josh B <joshb41_at_yahoo.com>
Date: Mon, 11 Apr 2011 12:29:09 -0700 (PDT)

Dear Listserv,

Here is my latest in a series of simple-seeming questions that dog me.

Consider the following data:

x <- read.table(textConnection("temperature probability 0.11 9.4
0 2.3

```0.38 8.7
0.43 9.2
0.6 15.6
0.47 8.7
0.09 12.8
0.11 9.4
0.01 7.7
0.83 8
0.65 9.3
0.05 7.4
0.34 10.1
0.02 4.8
0.07 9.1
0.6 15.6
0.01 8.4
0.9 9.6
0.83 8
0.12 8.4
0.01 8
```

0 5
```0.11 9.7
0.41 7.4
0.05 9.4
0.09 8.3
```

0 6.1
0.12 8.4
0.73 7.8
0 4.2"), header = TRUE, as.is = TRUE)
closeAllConnections()

I modeled the relationship: Probability = f(Temperature), i.e., probability as a function of temperature.

I found that there is a significant quadratic term in the model:

summary(lm(x[,2] ~ x[,1] + I(x[,1]^2)))

Now the question is: how do I plot it?

I can do this:
plot(x[,2] ~ x[,1])

...but I would also like to add a line corresponding to the quadratic function. In other words, I want to visually show the relationship among the variables that is being modeled. How do I do it? I think the curve() command will be used, but I don't know how to employ it.

Sincerely,

Josh Banta, Ph.D
Center for Genomics and Systems Biology
New York University
100 Washington Square East
New York, NY 10003
Tel: (212) 998-8465
http://plantevolutionaryecology.org

[[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 Mon 11 Apr 2011 - 20:22:24 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 12 Apr 2011 - 06:20:29 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.