0

Consider the following plot:

 par(xaxs='i',yaxs='i') q = c(1000000,1051548,1073218,1087563,1097765,1109949,1113169,1124302,1134923,1137264,1132633,1235922,1351977,1474207,1602776,1746385,1905937,2077873,2276724,2487994,2718546,2939262,3209654,3543057,3858329,4243562,4301907,4332465,4392545,4412729,4429758) x <- seq(0,30, by = 1) plot(x, q, type = "l", bty = "L", ylim = c(0, max(q2)), xlim = c(0,30), xaxt = 'n', yaxt = 'n', xlab = "", ylab = "") points(20, q[20]) 

enter image description here

I am plotting the line q and the point with coordinates (20,q[20]). The weird thing is that the point doesn't get plotted on the line, while it actually belongs to the line..

I am not sure what I am doing wrong here. I have been trying to solve this problem for over an hour!!

Thanks!

3
  • 2
    Do points(20, q[21]). Your x vector sequence is from 0 to 30, but R indexes starting from 1. 20 in your x is the 21st element. Commented Oct 23, 2013 at 20:09
  • I think I have been in front of a screen for too long today. Very obvious mistakes. Thanks for helping out! Commented Oct 23, 2013 at 20:10
  • 1
    No worries. Happens to all of us. Commented Oct 23, 2013 at 20:10

1 Answer 1

1

R starts it's index with 1. That means you have to run points(20, q[21]) do get the point on the line.

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.