I am displaying time (hour, minute) ticks on the x-axis in Matplotlib with
plt.gca().xaxis.set_major_formatter(matplotlib.dates.DateFormatter("%H:%M"))
However, what is happening is that my ticks are not "nice" numbers. The automatic locating of the ticks gives me 10:34, 11:04, 11:34, etc. whereas I want 10:30, 11:00, 11:30, etc.
How do I fix the ticks to be at the times I want? Is there a way to shift all tick numbers by a certain amount when using times (4 minutes in my example)?
Try using the MinuteLocator
to limit the ticks to minutes 0 and 30:
minloc = matplotlib.dates.MinuteLocator(byminute=[0, 30])
plt.gca().xaxis.set_major_locator(minloc)