How to plot a smooth line with PyPlot and Python?

Sometimes, we want to plot a smooth line with PyPlot and Python.

In this article, we’ll look at how to plot a smooth line with PyPlot and Python.

How to plot a smooth line with PyPlot and Python?

To plot a smooth line with PyPlot and Python, we can use the spline function.

For instance, we write

from scipy.interpolate import spline

xnew = np.linspace(T.min(), T.max(), 300)  

power_smooth = spline(T, power, xnew)

plt.plot(xnew, power_smooth)
plt.show()

to call splint with 300 to let us plot 300 points between T.min() and T.max().

Then we call plot with xnew and power_smooth to plot a smooth plot.

Conclusion

To plot a smooth line with PyPlot and Python, we can use the spline function.