title: How to change xticks with matplotlib?
body: <p>I want to change xticks on a plot with matplotlib, say replacing for instance with a string. According to matplotlib manual <a href="https://matplotlib.org/3.1.0/api/_as_gen/matplotlib.pyplot.xticks.html" rel="nofollow noreferrer">https://matplotlib.org/3.1.0/api/_as_gen/matplotlib.pyplot.xticks.html</a> I did the following code :</p>
  
  <pre><code>import matplotlib.pyplot as plt
  import numpy as np
  
  x=np.arange(10)
  y=x**2
  plt.figure()
  plt.plot(x,y)
  locs, labels=plt.xticks()
  new_xticks=['test' for d in locs]
  plt.xticks(new_xticks, rotation=45, horizontalalignment='right')
  </code></pre>
  
  <p>The problem is when I do this, ticks on x axis are not modified, and I get the following error</p>
  
  <blockquote>
    <p>ConversionError: Failed to convert value(s) to axis units: ['test',
    'test', 'test', 'test', 'test', 'test', 'test']</p>
  </blockquote>
  
  <p>EDIT : I want to have the ticks at the same place of the original plot, which x axis don't go beyond min and max value, as in the following picture :
  <a href="https://i.stack.imgur.com/QE3Dq.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/QE3Dq.png" alt="plot"></a></p>
  
  <p>Thanks in advance for your help !</p>
  
  <p>EDIT2 : its not a duplicate as I do it directly without using subplots</p>