用多个 x 轴标记 y 轴'

Labeling y-axis with multiple x-axis'

我已经在不同的尺度上设置了一个具有 3 个 x 轴的图,但是当我尝试使用 Y 标签时出现错误:

A​​ttributeError: 'function' 对象没有属性 'ylabel'

我尝试了多种选择,但我不确定为什么会出现此错误。

我的代码:

fig, ax = plt.subplots()

fig.subplots_adjust(bottom=0.30)

ax1 = ax.twiny()
ax2 = ax.twiny()

ax1.set_frame_on(True)
ax1.patch.set_visible(False)
ax1.xaxis.set_ticks_position('bottom')
ax1.xaxis.set_label_position('bottom')
ax1.spines['bottom'].set_position(('outward', 60))

ax.plot(temp1, depth1, "r-")
ax1.plot(v1, depth1, "g-.")
ax2.plot(qc1, depth1, "b--")

ax1.axis((0, 200, 0, 20))
ax.invert_yaxis()
ax.xaxis.set_major_locator(MaxNLocator(integer=True))

ax.set_xlabel('Temperature [\N{DEGREE SIGN}C]', color='r')
ax1.set_xlabel('Volumetric moisture content [%]', color='g')
ax2.set_xlabel('Cone tip resistance [MPa]', color='b')

ax.set.ylabel('Depth [m]')

for tl in ax.get_xticklabels():
    tl.set_color('r')
for tl in ax1.get_xticklabels():
    tl.set_color('g')
for tl in ax2.get_xticklabels():
    tl.set_color('b')

ax.tick_params(axis='x', colors='r')
ax1.tick_params(axis='x', colors='g')
ax2.tick_params(axis='x', colors='b'

)

您正在输入 ax.set.ylabel,您应该输入 ax.set_ylabel