How can I change the font of a datetime x-axis in Matplotlib?
The ax.xaxis.set_major_formatter(mdates.DateFormatter("%Y-%m-%d"))
from other answers only allows to change the date format, not the text formatting (font family, type, etc.), and ax.set_xticklabels(ax.get_xticklabels(), **font_prop)
also doesn't work because ax.get_xticklabels()
returns numbers instead of datetime objects and I have failed to convert them back to dates.