Home > Visualization > Main text

Line plot


Tag: plot, visualization

Smooth line in pyplot stackoverflow

from scipy.interpolate import spline

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])

#300 represents number of points to make between T.min and T.max
xnew = np.linspace(T.min(),T.max(),300) 

power_smooth = spline(T,power,xnew)

plt.plot(xnew,power_smooth)
plt.show()
Not smooth Smooth

If you link this blog, please refer to this page, thanks!
Post link:https://tsinghua-gongjing.github.io/posts/lineplot.html

Previous: Algorithm: 数据结构和算法的可视化