Unevenly spaced x in a plot (automatic plotting of functions)

I recently learned that I can plot a function f(x) as follows.

using Plots
f(x) = 1/(1+exp(-x))
scatter(f, (-10.0,10.0)...)

And, I noticed that the plot is not evenly spaced with respect to the x-axis when plotted with a scatter as shown in the figure. There are more points clustered where the curve is steeper and fewer points where it is less varied. There seems to be some kind of mathematical intelligence behind it.


How are the x coordinates of each of these points being generated?
Is there a function that returns such an unevenly spaced x coordinates when given f(x)?

Your code doesn’t run for me (julia 1.8.5).
Maybe you left some lines out…
What packages are you using?

Oh, I used Plots v1.38.3 with GR backend on Julia v.1.8.5. I updated the code.

Check this relevant Plots.jl’s issue, from which we can learn that the code is in file adapted_grid.jl. It seems to be using the curvature (second derivative).


Thank you for your comment and link. This helps me a lot!