2

I'm plotting some functions in R. Some of them aren't continuous and I get a vertical line between the diferent curve components. I really need to get this vertical line out (It makes the function look like a no-function and I don't want that).

So, how can I do that? Right now, I'm using two vectors x andy and doing plot(x,y,type = "l") so R doesn't understand where there is a discontinuity. But I didn't find a better way.

VR_1312
  • 151
  • 1
  • 13
  • If you need concrete help you'll need to provide [a more concrete, reproducible example (click here for tips)](http://stackoverflow.com/q/5963269/903061). – Gregor Thomas Mar 15 '17 at 03:23

1 Answers1

1

It might not be the optimum solution, but if the number of functions is small you could split them leaving the continous parts, then just use plot for the first one and add the other with lines. e.g.:

  x <- seq(1,3,1)
  y <- sqrt(x) 
  x2 <-  seq(3,6,1)
  y2 <- runif(4)

  plot(y ~ x, type = "l",col = 2 , ylim = c(0,2) , xlim = c(0,6))
  lines(y2 ~ x2, col = 2)
Zheyuan Li
  • 71,365
  • 17
  • 180
  • 248
Edgar Santos
  • 3,426
  • 2
  • 17
  • 29