- 积分
- 85
- 贡献
-
- 精华
- 在线时间
- 小时
- 注册时间
- 2012-11-26
- 最后登录
- 1970-1-1
|
登录后查看更多精彩内容~
您需要 登录 才可以下载或查看,没有帐号?立即注册
x
如题,为什么执行脚本之后色标柱刻度都是空的,我想设置成最大值最小值顶格显示
fn = r'K:\MI\data\T-RH.txt'
table = readtable(fn, format='%3f')
tm = table['T']
o3 = table['O3']
rh = table['RH']
# 对数拟合:y = a * x^b
# 计算 ln(T) 和 ln(O3)
log_tm = [log(t) for t in tm]
log_o3 = [log(o) for o in o3]
# 执行线性回归(对数拟合)
#slope, intercept, r, p, std_err = stats.linregress(tm, o3)
slope, intercept, r, p, std_err = stats.linregress(log_tm, log_o3)
# 生成拟合曲线
#x = arange(4, 40, 2)
#y = fitting.polyval([slope, intercept], x)
x_fit = arange(20, 38, 0.1)
y_fit = [exp(intercept) * (x ** slope) for x in x_fit] # y = e^b * x^a
# 绘制散点图(带RH颜色映射)
#scatter(tm, o3, s=2, color='k', label='PM')
#the following 2lines is with RH
ls = scatter(tm,o3,s=8,c=rh,cmap='NCV_jet',edgecolor=None,cnum=100,vmin=-0.1, vmax=100.1)
colorbar(ls,ticks=[0,20,40,60,80,100],extendfrac=None,fontsize=14,tickin=True,label='RH(%)')
# 绘制对数拟合曲线
plot(x_fit, y_fit, 'black-', linewidth=2, label='Log Fit')
#plot(x, y, 'b-', linewidth=2)
# 设置坐标轴范围和刻度
xlim(18, 40)
ylim(0, 320)
xticks(arange(18, 41, 2)) # x轴刻度从22到40,间隔2
yticks(arange(0, 321, 40)) # y轴刻度从40到320,间隔40
xaxis(tickin=True)
yaxis(tickin=True)
# 添加标签和公式
xlabel(r'$\rm{T} \ (^{\circ} \ C)$')
ylabel(r'$\rm{O_{3}} \ (\mu g/ \ m^{3})$')
#text(21, 300, r'$y = ' + '%.4f' % slope + 'x +' + '%.4f' % intercept + '$', fontsize=14)
text(19, 300, r'$y = %.4f \cdot x^{%.4f}$' % (exp(intercept), slope), fontsize=14)
text(19, 285, r'$R^2 = '+ '%.4f' % (r * r) + '$', fontsize=14) |
-
|