1

I have a function

1.0 * (375 - 515) * exp(-0.01 * x) + 515

in which x = time in milliseconds. I would like to draw that line in an R plot within a given range of x (in my case between 80 and 250), with x on the x-axis and a given range 800-300 on the y-axis (the intersection between the axes being where x = 80 and y = 800).

How can I do this?

Sverre
  • 747
  • 2
  • 8
  • 19
  • This is a very basic question. What have you tried? Where are you stuck? – sgibb Aug 10 '13 at 13:45
  • 1
    I'm sure it's very basic if you have the necessary knowledge to do such things - which I don't. I googled around a bit, but I only found guides for plotting/drawing lines through data points from a data frame, and I know how to do that already. So I'm stuck at the very beginning - I don't even know where to start. – Sverre Aug 10 '13 at 13:53

1 Answers1

4

You could have a look at the curve function in R:

?curve

Something like this will get you started:

curve(1.0 * (375 - 515) * exp(-0.01 * x) + 515, from=80, to=250,ylim=c(300,800))

Why do you want the axes to intersect at (80,800)?

CnrL
  • 2,558
  • 21
  • 28
  • The y-axis in this case refers to a measure which by convention has its higher values at the bottom and its lower values at the top (I found out how to do that). I want the x-axis to begin at 80 and stop at 250 because the function refers to observations only in that range - it's not meant to predict beyond it. – Sverre Aug 10 '13 at 13:58
  • 1
    In that case, you might like to reverse the order of the limits in the ylim argument (i.e. change to c(800,300)) – CnrL Aug 10 '13 at 14:02