我希望能够显示一个对象;在我的 matplotlib 图表上将其称为“坡度”。例如:
import numpy as np
import matplotlib.pyplot as plt
range1 = a[(-5. <= a) & (-3. >= a)]
range2 = b[(-5. <= a) & (-3. >= a)]
'''Calculate slope value from endpoints in the data range (linear).'''
xslopeentry1 = range1[0]
xslopeentry2 = range1[-1]
yslopeentry1 = range2[0]
yslopeentry2 = range2[-1]
Slope = (yslopeentry2-yslopeentry1)/(xslopeentry2-xslopeentry1)
plt.plot(range1,range2)
plt.show()
现在,我将如何能够“打印”或在我的绘图上显示为“斜率”获得的值?