x <- seq(from=-50,to=50,by=0.1)
y<--x^2+2500
ylims <- range(y)
plot(x,y,type="l",ylim = ylims)
y[y>1000]<-NA
plot(x,y,type="l", ylim = ylims)
## tidyverse ====
x <- seq(from=-50,to=50,by=0.1)
y<--x^2+2500
library(tidyverse)
p <- tibble(x,y) %>%
mutate(yCutoff = ifelse(y>1000, NA, y)) %>%
ggplot(aes(x,y)) +
geom_line(aes(y = yCutoff)) +
ylim(range(y)) +
theme_minimal()
p
# your x-Values:
p$data %>% filter(is.na(yCutoff))%>% select(x)
#> # A tibble: 775 x 1
#> x
#> <dbl>
#> 1 -38.7
#> 2 -38.6
#> 3 -38.5
#> 4 -38.4
#> 5 -38.3
#> 6 -38.2
#> 7 -38.1
#> 8 -38
#> 9 -37.9
#> 10 -37.8
#> # … with 765 more rows