Skip to content Skip to sidebar Skip to footer

[matplotlib]: Write Dates On X Axis

Here an example code in which I would like to draw the entire date on the x axis import datetime import matplotlib.pyplot as plt import random import numpy as np from matplotlib.da

Solution 1:

ax.fmt_xdata is the formatter for the dates usually only used for the hover functionality in interactive plots. enter image description here

What you want here is to set the major formatter of the xaxis to a DateFormatter:

ax.xaxis.set_major_formatter(DateFormatter('%b-%d-%Y'))

enter image description here


Post a Comment for "[matplotlib]: Write Dates On X Axis"