Если вы просто хотите изменить метки по умолчанию вручную (см., Например, этот ответ ), должно работать следующее (после выполнения уже выполненных вами команд):
plt.draw() # do this so that the labels are generated
ax = plt.gca() # get the figure axes
xticks = ax.get_xticklabels() # get the current x-tick labels
newlabels = []
for label in xticks:
h, m = divmod(float(label.get_text())%12, 1) # get hours and minutes (in 12 hour clock)
newlabels.append('{0:02d}:{1:02d}'.format(int(h), int(m*60))) # create the new label
ax.set_xticklabels(newlabels) # set the new labels
Но если вы хотите, чтобы ребра гистограмм были специально настроены на интервалы в 10 минут, вы можете сделать следующее:
import numpy as np
# get a list of the times
times = [t.hour + t.minute/60. for t in df['ARRIVAL TIME']]
# set the time interval required (in minutes)
tinterval = 10.
# find the lower and upper bin edges (on an integer number of 10 mins past the hour)
lowbin = np.min(times) - np.fmod(np.min(times)-np.floor(np.min(times)), tinterval/60.)
highbin = np.max(times) - np.fmod(np.max(times)-np.ceil(np.max(times)), tinterval/60.)
bins = np.arange(lowbin, highbin, tinterval/60.) # set the bin edges
# create the histogram
plt.hist(times, bins=bins)
ax = plt.gca() # get the current plot axes
ax.set_xticks(bins) # set the position of the ticks to the histogram bin edges
# create new labels in hh:mm format (in twelve hour clock)
newlabels = []
for edge in bins:
h, m = divmod(edge%12, 1) # get hours and minutes (in 12 hour clock)
newlabels.append('{0:01d}:{1:02d}'.format(int(h), int(m*60))) # create the new label
ax.set_xticklabels(newlabels) # set the new labels