在python中获得X和Y轴上对数刻度的线性回归曲线

问题描述

下午好!从我的数据中,我可以得到线性回归曲线,到目前为止还不错,有这些线。

slope,intercept,r_value,p_value,std_err = stats.linregress(A,B)
print('Slope: ',slope,'\nIntercept: ',intercept)
def predict_y_for(A):
    return slope * A + intercept

plot(A,B,'^')
plot(A,predict_y_for(A),'r')
plt.show()

从这个 e 得到以下情节:

linear scale

但是,我需要在 X 和 Y 轴上使用对数刻度来获得曲线,所以我这样做了:

plot(A,'r')
plt.xscale('log')
plt.yscale('log')    
plt.show()

现在我得到了多条线而不是一条线:

log scale

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)