I've got the following simple script that plots a graph:
import matplotlib.pyplot as plt
import numpy as np
T = np.array([6, 7, 8, 9, 10, 11, 12])
power = np.array([1.53E+03, 5.92E+02, 2.04E+02, 7.24E+01, 2.72E+01, 1.10E+01, 4.70E+00])
plt.plot(T,power)
plt.show()
As it is now, the line goes straight from point to point which looks ok, but could be better in my opinion. What I want is to smooth the line between the points. In Gnuplot I would have plotted with smooth cplines
.
Is there an easy way to do this in PyPlot? I've found some tutorials, but they all seem rather complex.
Best Answer
You could use
scipy.interpolate.spline
to smooth out your data yourself:Switching from
spline
toBSpline
isn't a straightforward copy/paste and requires a little tweaking:Before:
After: