Subplot() and plot()

why not use plot() in the situation below?
ax = plt.subplot()
ax.set_xticks(months)
ax.set_xticklabels(month_names)

Guessing this is matplotlib.pyplot: import matplotlib.pyplot as plt

You might need to give a bit more of an example or consider linking to the lesson your query realtes to. Setting ticks and labels before plotting data is a curious way of going about things.

If instead you meant why are not calling plt.xticks() or similar instead: It’s generally a good to reference the axis (or figure, or plot etc.) directly. A number of plt methods rely on the current figure or axis. What happens when you have more than one figure or multiple axes per figure… to put it politely, it can become rather messy.

Wherever possible I’d suggest you use methods associated with these particular objects if only for the sake of your own sanity.