【发布时间】:2019-10-22 03:07:12
【问题描述】:
基本上我有一个数据集,我只想找到我绘制的线段的斜率。我看到的每个答案都只解释了如何创建最适合的一般线,但这与我的需要无关。
我在 python 3 中使用 Jupyter Notebook,带有 pandas、matplotlib.pyplot、numpy,并从 scipy.stats 导入了 linregress(根据另一篇解释如何计算斜率的帖子的说明)。
这是我使用定义为 df 和 df2 的两个数据框绘制的图。
plt.figure(figsize=(20,10))
line1 = plt.plot(df['Time (s)'],df['Oxygen (μmol/L)'], 'b-', label='1mM Ru(Eto)(bpy) with 20eq Ce')
line2 = plt.plot(df2['Time (s)'],df2['Oxygen (μmol/L)'], 'r-', label='1mM Ru(tpy)(bpyCO)PF_6 with 20eq Ce')
plt.legend()
基本上我想在线条不完全平坦的地方显示最佳拟合线的斜率。
【问题讨论】:
标签: python-3.x pandas matplotlib jupyter-notebook