2016-10-14 252 views
0

我已經建立了一個陰謀與3 x軸上不同尺度,但是當我嘗試使用Y型標籤我得到的錯誤:標籤y軸與多個x軸

AttributeError的:'函數'對象沒有屬性'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' 

回答

0

你輸入ax.set.ylabel,你應該做ax.set_ylabel

+0

哇哦,這是一個很容易解決,謝謝你指出這一點。 – Scott