title: AttributeError: 'AxesSubplot' object has no property 'axes_class' when trying to left align ticks of the y axis of a plot
body: <p>I'm trying to left align ticks of the y axis of a plot and copied the code on the <a href="https://matplotlib.org/stable/gallery/axisartist/demo_ticklabel_alignment.html" rel="nofollow noreferrer">matplotlib documentation</a> but I get an error message <code>AttributeError: 'AxesSubplot' object has no property 'axes_class'</code> with <code>matplotlib==3.3.3</code> and <code>Python 3.8.7</code></p>
  <pre><code>import matplotlib.pyplot as plt
  import mpl_toolkits.axisartist as axisartist
  
  
  def setup_axes(fig, pos):
      ax = fig.add_subplot(pos, axes_class=axisartist.Axes)
      ax.set_yticks([0.2, 0.8], labels=[&quot;short&quot;, &quot;loooong&quot;])
      ax.set_xticks([0.2, 0.8], labels=[r&quot;$\frac{1}{2}\pi$&quot;, r&quot;$\pi$&quot;])
      return ax
  
  
  fig = plt.figure(figsize=(3, 5))
  fig.subplots_adjust(left=0.5, hspace=0.7)
  
  ax = setup_axes(fig, 311)
  ax.set_ylabel(&quot;ha=right&quot;)
  ax.set_xlabel(&quot;va=baseline&quot;)
  
  ax = setup_axes(fig, 312)
  ax.axis[&quot;left&quot;].major_ticklabels.set_ha(&quot;center&quot;)
  ax.axis[&quot;bottom&quot;].major_ticklabels.set_va(&quot;top&quot;)
  ax.set_ylabel(&quot;ha=center&quot;)
  ax.set_xlabel(&quot;va=top&quot;)
  
  ax = setup_axes(fig, 313)
  ax.axis[&quot;left&quot;].major_ticklabels.set_ha(&quot;left&quot;)
  ax.axis[&quot;bottom&quot;].major_ticklabels.set_va(&quot;bottom&quot;)
  ax.set_ylabel(&quot;ha=left&quot;)
  ax.set_xlabel(&quot;va=bottom&quot;)
  
  plt.show()
  </code></pre>
  <p><strong>Edit</strong></p>
  <p>I tried to remove the <code>mpl_toolkits.axisartist</code> and changed the line <code>ax.axis[&quot;left&quot;].major_ticklabels.set_ha(&quot;left&quot;</code> to <code>ax.yaxis.major_ticklabels.set_ha(&quot;left&quot;)</code> as mentioned in the comment but got the error message:</p>
  <p><code>AttributeError: 'YAxis' object has no attribute 'major_ticklabels'</code></p>
  <pre><code>import matplotlib.pyplot as plt
  #import mpl_toolkits.axisartist as axisartist
  
  
  def setup_axes(fig, pos):
    #    ax = fig.add_subplot(pos, axes_class=axisartist.Axes)
      ax = fig.add_subplot(pos)
      ax.set_yticks([0.2, 0.8], labels=[&quot;short&quot;, &quot;loooong&quot;])
      ax.set_xticks([0.2, 0.8], labels=[r&quot;$\frac{1}{2}\pi$&quot;, r&quot;$\pi$&quot;])
      return ax
  
  
  fig = plt.figure(figsize=(3, 5))
  fig.subplots_adjust(left=0.5, hspace=0.7)
  
  
  ax = setup_axes(fig, 311)
  #ax.axis[&quot;left&quot;].major_ticklabels.set_ha(&quot;left&quot;)
  #ax.axis[&quot;bottom&quot;].major_ticklabels.set_va(&quot;bottom&quot;)
  ax.yaxis.major_ticklabels.set_ha(&quot;left&quot;)
  #ax.axis.major_ticklabels.set_va(&quot;bottom&quot;)
  ax.set_ylabel(&quot;ha=left&quot;)
  ax.set_xlabel(&quot;va=bottom&quot;)
  
  plt.show()
  
  </code></pre>