最佳答案
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.