R segment function with intervals -



R segment function with intervals -

i having problem understanding segments function in base of operations graphics in context of specific problem.

x <- 0:1000 y <- c(0, 40000, 80000)

now want draw plot line 0 200 @ y=0. line 200 500 @ y=40000 , lastly line 500 1000 @ y=80000.

plot(x,y,type="n") segments(0,0,200,40000,200,40000,500,8000,1000) points(0,0,200,40000,200,40000,500,8000,1000) points(0,0,200,40000,200,40000,500,8000,1000)

i believe wrong define exact segments here. if x 0:3 knwo do. have in case of intervals?

you need supply vectors of coordinates x0 , y0 , x1 , y1 x , y coordinates draw , respectively. consider next working example:

x <- seq(0, 1000, length = 200) y <- seq(0, 80000, length = 200) plot(x,y,type="n") from.x <- c(0, 200, 500) to.x <- c(200, 500, 1000) to.y <- from.y <- c(0, 40000, 80000) # , y coords same segments(x0 = from.x, y0 = from.y, x1 = to.x, y1 = to.y)

this produces next plot

r intervals segments

Comments

Popular posts from this blog

php - Android app custom user registration and login with cookie using facebook sdk -

django - Access session in user model .save() -

php - .htaccess Multiple Rewrite Rules / Prioritizing -