Используйте from
и to
:
plot(fun,from=0,to=10,xlim=c(-10,20))
![from-and-to](https://i.stack.imgur.com/m1ehU.jpg)
Или в качестве альтернативы в ggplot2
, сначала настройте окно фиктивного графика,затем используйте stat_function
с xlim
и scale_x_continuous
.Обратите внимание, что xlim
работает здесь совсем не так, как в базовой R.
fun <- function(t) { sin(2*pi*t) - 0.5*cos(2*pi*t)}
p <- ggplot(data=data.frame(x=0), mapping=aes(x=x))
p + stat_function(fun=fun, xlim=c(0,10)) +
scale_x_continuous(limits=c(-10,20))
![enter image description here](https://i.stack.imgur.com/dwLGa.jpg)