`Plots.jl` spline

Honestly, this is a pretty heavy weight function for a plotting package to implement. If I was to do that, I would probably start by importing Interpolations.jl or some other spline package, and that would add an unacceptable dependency to Plots. It’s better to explicitly generate the spline and then plot it.

I am, however, a bit confused as to why plot(b::Interpolations.Extrapolation) is not by default equivalent to plot(x->b(x)), which would make this pretty much seamless. Nonetheless, here’s how to do what you want:

using Interpolations, Plots
y = [1, 10, 3, 9]
x = axes(y)
b = cubic_spline_interpolation(x, y)
plot(x, y; seriestype=:scatter)
plot!(x->b(x); seriestype=:path)
2 Likes