title: Is it possible to format the labels using set_xticklabels in matplotlib?
body: <p>In order to set the labels of an axis object, one uses the <code>xticklabels</code> method:</p>
  
  <pre><code>fig, ax = plt.subplots()
  ax.imshow(np.eye(101))
  labels = np.linspace(2, 4, 4)
  ax.set_xticks([0, 33, 66, 100])
  ax.set_xticklabels(labels)
  </code></pre>
  
  <p>Which gives:</p>
  
  <p><img src="https://i.stack.imgur.com/07zJH.png" alt="1"></p>
  
  <p>It is also possible to format the labels using a <a href="https://matplotlib.org/api/ticker_api.html#tick-formatting" rel="noreferrer">formatter</a>:</p>
  
  <pre><code>fig, ax = plt.subplots()
  labels = np.linspace(2, 4, 4)
  ax.imshow(np.eye(101))
  ax.set_xticks([0, 33, 66, 100])
  ax.set_xticklabels(labels)
  ax.xaxis.set_major_formatter(FormatStrFormatter('%.2f'))
  </code></pre>
  
  <p>But the formatter only uses the tick position, and not his label:</p>
  
  <p><img src="https://i.stack.imgur.com/OCNzb.png" alt="2"></p>
  
  <p>The workaround is to manually format the labels before using <code>set_xticklabels</code>:</p>
  
  <pre><code>fig, ax = plt.subplots()
  labels = ["{0:.1f}".format(x) for x in np.linspace(2, 4, 4)]
  ax.imshow(np.eye(101))
  ax.set_xticks([0, 33, 66, 100])
  ax.set_xticklabels(labels)
  </code></pre>
  
  <p><img src="https://i.stack.imgur.com/pUOCY.png" alt="3"></p>
  
  <p>So, there are two questions:</p>
  
  <ol>
  <li>Is it possible to format to the labels when using <code>set_xticklabels</code> function? For example, by using a format string.</li>
  <li>What is the link between <code>set_xticklabels</code> and the <a href="https://matplotlib.org/api/ticker_api.html#tick-formatting" rel="noreferrer">Formatter</a>? It appears that the Formatter is not taking <code>set_xticklabels</code> at all into account, and produces the labels by itself.</li>
  </ol>