[SciPy-user] "smooth" plots

Robert Kern robert.kern at gmail.com
Wed Apr 1 15:22:47 EDT 2009


On Wed, Apr 1, 2009 at 12:36, Jonathan Guyer <guyer at nist.gov> wrote:
> Lets say I want to plot y = f(x).
>
> f() is non-analytical and expensive.
>
> Are there any facilities in SciPy (or elsewhere in Python) for
> automating the selection of values of x that will produce a "smooth"
> plot of y vs. x? The only mentions I've seen for adaptive step size
> selection are for the ode integrators, which I'm not doing. Likewise,
> the splines and other smoothing functions don't seem appropriate
> because I don't have noisy data; I'm trying to figure out what data I
> even need to calculate (which will probably not be noisy at all).

Most of the spline fitting in scipy.interpolate is for exact
interpolation and not noisy data. If your function is smooth (C0 and
C1 continuous), and there are no singularities, then the most
straightforward thing to do would be to do a coarse sampling of your
function, spline fit it, and then evaluate the spline finely. This is,
of course, approximate, but probably not too bad.

There is no adaptive sampling in scipy. That would require much more
information about the screen geometry and line thicknesses. We leave
that to the plotting frameworks. You might want to check SAGE for this
functionality; they would often have need for it.

-- 
Robert Kern

"I have come to believe that the whole world is an enigma, a harmless
enigma that is made terrible by our own mad attempt to interpret it as
though it had an underlying truth."
  -- Umberto Eco



More information about the SciPy-User mailing list