Sounds reasonable to me. The docs say it sets tick locations https://matplotlib.org/stable/api/_as_gen/matplotlib.axes.Axes.set_xticks.html#matplotlib.axes.Axes.set_xticks which I guess makes the locations fixed so you get around the issue.
The issue comes about as the xaxis uses the units as a form of spacing for ticks (normally). As a rather silly example plotting values from 0 to 10 for example you can set “xticks” to numerical values (increments of 0.1 from 0.4 to 0.9 here) and it will use their numerical locations as their labels-

Rather pointless in that example but it can be beneficial when you want custom labels but don’t want to have to set both position and label when they’re identical.
When you add strings as labels directly it doesn’t automatically know where on the axis to put them. It might try to put labels on existing tick locations, but this method is unreliable (I’ve definitely seen labels go missing entirely when relying on this, outside the range for example).
What you need is to explicitly state where on the axis the ticks should be and then you can make the labels for those ticks whatever you want. The warning is just because matplotlib does not guarantee that setting labels on ticks that used to be automatically placed on an axis will work correctly (this might be a silly error like a missing label or the labels could be shifted and suddenly your graph is wrong, it’s just a bit unpredictable).
Edit: Just found a simple example of this in practice. Depending on your viewer/screen size this could be different but I’ll show what happens on mine.
fig, ax = plt.subplots(1, 1)
ax.plot(range(10))
At this point the graph is boring but clear. There are 5 major VISIBLE ticks (0, 2, 4, 6, 8) and the range of the xaxis is perhaps around -0.2 to -9.8
What happens then if I force the ticks labels…
ax.set_xticklabels(["red", "orange", "yellow", "green", "blue"])
# At this point the output of xticklabels is-
#[Text(-2.0, 0, 'red'),
# Text(0.0, 0, 'orange'),
# Text(2.0, 0, 'yellow'),
# Text(4.0, 0, 'green'),
# Text(6.0, 0, 'blue'),
# Text(8.0, 0, ''),
# Text(10.0, 0, '')]
If you note the locations and labels you’ll already see they’ve gone a bit wonky. Some are outside our normal range, others have just gone missing. Upading the graph now with fig.canvas.draw()
I see-
So we’ve lost “red” and also introduced some empty ticks. As for why the original ticks were at these locations: [-2., 0., 2., 4., 6., 8., 10.]
. We can’t even see some of these ticks in the range we have but they’re there nontheless.
There are ways around this but I think the warning basically says, DON’T ASSUME for tick locations when applying text labels. They’re a fickle beast.