Why set_xticks doesn't set the labels of ticks?

matplotlib, python

Solution

`.set_xticks()` on the axes will set the locations and `set_xticklabels()` will set the displayed text.

def test(axes):
    axes.bar(x,y)
    axes.set_xticks(x)
    axes.set_xticklabels([i+100 for i in x])

Problem

``` import matplotlib.pyplot as plt x = range(1, 7) y = (220, 300, 300, 290, 320, 315) def test(axes): axes.bar(x, y) axes.set_xticks(x, [i+100 for i in x]) fig, (ax1, ax2) = plt.subplots(1, 2) test(ax1) test(ax2) ``` I am expecting the xlabs as `101, 102 ...` However, if i switch to use `plt.xticks(x, [i+100 for i in x])` and rewrite the function explicitly, it works.

Original source