如何在 plt.subplots 中添加 x 轴标签?

How would I add a x axis label in plt.subplots?

我有一个非常复杂的 plt.subplots 因为我试图绘制 29 个不同的图。一切似乎都正常,但我想在我的 x 轴上添加一个标签:

plt.figure(figsize=(30,30))
for i in range(int(len(fwf_tot_grnl.sum(dim=('X','Y')))/24)):

    # add a new subplot
    ax = plt.subplot(8, 4, i+1)

    # plot on the subplot
    ax.plot(time_months[i*24: (i+1)*24],fwf_tot_grnl.sum(dim=('X','Y'))[i*24: (i+1)*24])

    # other formating
    ax.set_xticks(np.arange(min(time_months[i*24: (i+1)*24]),max(time_months[i*24: (i+1)*24]),.25))

# want to add x label here!
    ax.set_xticklabels(['{:.2f}'.format(a) for a in np.arange(min(time_months[i*24: (i+1)*24]),max(time_months[i*24: (i+1)*24]),.25)], rotation=15)

    ax.grid()
    ax.set_title('FWF All Basins Monthly Data (2 year increments)')
    plt.tight_layout()

plt.show()

我想给这一行添加一个 xlabel:

ax.set_xticklabels(['{:.2f}'.format(a) for a in np.arange(min(time_months[i*24: (i+1)*24]),max(time_months[i*24: (i+1)*24]),.25)], rotation=15)

我只是尝试这样做:

ax.set_xticklabels(['{:.2f}'.format(a) for a in np.arange(min(time_months[i*24: (i+1)*24]),max(time_months[i*24: (i+1)*24]),.25), 'Time'], rotation=15)

但我收到此错误:

 File "<ipython-input-48-4e6a31743d8a>", line 13
    ax.set_xticklabels(['{:.2f}'.format(a) for a in np.arange(min(time_months[i*24: (i+1)*24]),max(time_months[i*24: (i+1)*24]),.25),'Time'], rotation=15)
                                                                                                                                    ^
SyntaxError: invalid syntax

如何向我的 plt.subplots 添加一个简单的 x 标签?

  ax.set_ylabel('FWF (km$^3$/yr)')
  ax.set_xlabel('Time')

我在看集合 x_ticks 而不是 xlabel!只需要做 set_ylabel/set_xlabel 来定义 x 和 y 轴标签。