Search code examples
pythonmatplotlibsmoothing

Simple curve smoothing in matplotlib --- equivalent to gnuplot's "smooth bezier"?


I have a set of points I want to plot in matplotlib, say:

x = [1,4,6,7,8]
y = [0.2, 0.4, 0.5, 0.6, 0.6]

In gnuplot, I used to be able to directly use the 'plot' command's smooth property to get a smooth curve on a graph, without having to preprocess the data.

Is there an equivalent in matplotlib---specify a set of points, and tell it how to smooth it, bezier or spline or something like that?

If not, what is the easiest way of accomplishing this?


Solution

  • I think scipy's interpolation and curve-fitting functions are the closest you are going to get. I don't know of anything built into matplotlib.