文章背景,记录python 小demo 集合
1、使用python matplotlib库描绘曲线
import matplotlib.pyplot as NLA
x_index = [0, 5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60, 65, 70, 75, 80, 85, 90, 95, 100]
y_index = [6.1, 7.4, 9.1, 11.1, 12.69, 14.35, 16.1, 17.7, 19.98, 21.26, 22.48, 24.5, 26.25, 27.9, 29.56, 31.2, 32.9, 34.78, 36.4, 39.1, 40]
def curve(x, y):
NLA.plot(x, y)
NLA.title("NonelinearCurve curve")
NLA.xlabel("Blacklight Value")
NLA.ylabel("PWM Value")
NLA.show()
if __name__=='__main__':
curve(x_index, y_index)
运行前先安装库:pip3 install matplotlib
效果如下