0

I've set up a plot with 3 x-axis' on different scales, however when i attempt to use a Y-label i get the error:

AttributeError: 'function' object has no attribute 'ylabel'

I've tried a number of options, however I am not sure why this error appears.

My code:

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'

)

Scott
  • 61
  • 7

1 Answers1

0

you are typing ax.set.ylabel, you should be doing ax.set_ylabel

WildCard
  • 527
  • 3
  • 8