Mayou
Mayou

Reputation: 8848

Odd graphing issue

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!

Upvotes: 0

Views: 65

Answers (1)

Christian
Christian

Reputation: 26427

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

Upvotes: 1

Related Questions