Control over sampling when plotting functions

Plotting functions in Julia is quite easy and works super nice for smooth functions. However, for more complex functions (switched), some points get lost.

f(x) = 0.6 > mod(x,1) > 0.5 ? 1 : 0
plot(f, xlims=(0,10))

Is there an easy way to control the sampling of the function without having to explicitly generate the x and f(x) vectors?

1 Like

There is plot(f:: Function, x::AbstractVector) which solves half of your question. What kind of control do you want?

1 Like

Thanks, that answers my question. Looking through the docs is hard. These work good:

plot(f, 0:0.001:3)
plot(f, range(0, stop=3, step=0.001))