Im learning matplotlib, and trying to draw a simple scatter plot that has dates on the x-axis and values on the y. There are 2200 dates, from 2004 to 2019, (format 2014-09-17 type O).
Heres my code:
x=df.DATE
y=df.CLOSE
plt.figure(figsize=(21,12))
plt.xticks(fontsize=8, rotation = 45)
plt.scatter(x,y)
The plot is great, but, obviously, the xaxis has 2000 entries on it! Ive checked the Matplotlib documentation (maybe its me but its not very noob-friendly, unlike the python documentation) and other posts on stackoverflow, as to how to reduce the number of labels (dates) written on the x-axis, and have found various commands: Axes.set_xticklabels(labels, *, fontdict=None, minor=False, **kwargs)set_xticks(), MaxNLocator(), autolocator, Axes.set_xticks(MaxNLocator(10)) and others. Ive tried all sorts of variations, but none of them work. And many require "ax." which I havent used and when I try axes it tells me its not defined.
Im stumped. Any simple way I reduce the number of entries on the x-axis to, say a maximum of "n" dates or one date every 10?
Thanks!