0

異なるスケールで 3 つの x 軸を持つプロットを設定しましたが、Y ラベルを使用しようとするとエラーが発生します。

AttributeError: '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'

)

4

1 に答える 1