我正在尝试使用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)
答案 0 :(得分:0)
您可以使用numpy.amax
和numpy.amin
函数来获取数组中温度轴的最大值和最小值(https://docs.scipy.org/doc/numpy-1.10.1/reference/generated/numpy.amax.html#numpy.amax)
使用numpy.argmax
您还可以获得最大值的索引(时间)