title: matplotlib axis arrow tip
body: <p>I am trying to set an arrow at the end of a an axis in matplotlib.
  I don't want to remove the spines and replace them with pure arrows because I need their functionalities ...</p>
  
  <p>my implementation <a href="https://gist.github.com/joferkington/3845684" rel="noreferrer">is as slight modification of joferkington implementation</a></p>
  
  <pre><code>import matplotlib.pyplot as plt
  import numpy as np
  
  def arrowed_spines(ax=None, arrowLength=30, labels=('X', 'Y'), arrowStyle='&lt;|-'):
      xlabel, ylabel = labels
  
      for i, spine in enumerate(['left', 'bottom']):
          # Set up the annotation parameters
          t = ax.spines[spine].get_transform()
          xy, xycoords = [1, 0], ('axes fraction', t)
          xytext, textcoords = [arrowLength, 0], ('offset points', t)
  
          # create arrowprops
          arrowprops = dict( arrowstyle=arrowStyle,
                             facecolor=ax.spines[spine].get_facecolor(), 
                             linewidth=ax.spines[spine].get_linewidth(),
                             alpha = ax.spines[spine].get_alpha(),
                             zorder=ax.spines[spine].get_zorder(),
                             linestyle = ax.spines[spine].get_linestyle() )
  
          if spine is 'bottom':
              ha, va = 'left', 'center'
              xarrow = ax.annotate(xlabel, xy, xycoords=xycoords, xytext=xytext, 
                          textcoords=textcoords, ha=ha, va='center',
                          arrowprops=arrowprops)
          else:
              ha, va = 'center', 'bottom'
              yarrow = ax.annotate(ylabel, xy[::-1], xycoords=xycoords[::-1], 
                          xytext=xytext[::-1], textcoords=textcoords[::-1], 
                          ha='center', va=va, arrowprops=arrowprops)
      return xarrow, yarrow
  
  # plot
  x = np.arange(-2., 10.0, 0.01)
  plt.plot(x, x**2)
  plt.gcf().set_facecolor('white')    
  ax = plt.gca()
  ax.set_xticks([]) 
  ax.set_yticks([]) 
  
  ax.spines['left'].set_position('center')
  ax.spines['right'].set_color('none')
  ax.spines['bottom'].set_position('center')
  ax.spines['top'].set_color('none')
  
  arrowed_spines(ax)
  
  plt.show()
  </code></pre>
  
  <p>The plot result shows a shift in the arrow as the following <a href="https://i.stack.imgur.com/Rhmo9.png" rel="noreferrer"><img src="https://i.stack.imgur.com/Rhmo9.png" alt="enter image description here"></a></p>
  
  <p>It seems that a shift of a point or two is consistent in the starting position and the alignment of the arrow with the spine. I don't know how to fix this problem. Any help would be appreciated.</p>
  
  <p>thanks</p>