我试图用Python绘制温度的最大/最小值。到目前为止,我只能绘制出一段时间内记录的所有温度。下面是我正在使用的代码。有什么建议只捕捉T_ch
(室内温度)的最大值和最小值?在
fig905, f905ax = plt.subplots(nrows=4, ncols=4, figsize=(16, 12))
for i in range(1, 5):
for j, sn in enumerate(['DJF', 'MAM', 'JJA', 'SON']):
f905ax[i - 1, j].plot(hr_local_int[(ch_no.values == i) & (season == sn)],
df_flux.loc[(ch_no.values == i) & (season == sn), 'T_ch' +str(i)],
'.', color=color_list[i - 1])
f905ax[i - 1, j].set_xlim((-0.5, 24.))
f905ax[i - 1, j].xaxis.set_major_locator(MultipleLocator(3))
f905ax[i - 1, j].xaxis.set_minor_locator(MultipleLocator(1))
if i == 1:
f905ax[0, j].set_title(sn)
f905ax[i - 1, 0].set_ylabel('ch' + str(i) + ' Temperature (C)')
for j in range(4):
f905ax[3, j - 1].set_xlabel('Hour (PDT, UTC-7)')
fig905.tight_layout()
fig905.savefig(plot_dir + '/ch_plots/Tch_diurnal.png', dpi=300)
您可以使用
numpy.amax
和numpy.amin
函数来获得数组中温度轴的最大值和最小值(https://docs.scipy.org/doc/numpy-1.10.1/reference/generated/numpy.amax.html#numpy.amax)使用
numpy.argmax
还可以获得最大值的索引(时间)相关问题 更多 >
编程相关推荐