Следующий код генерирует график с несколькими отметками, но мне нужно отображать отметку каждые 4 или 6 часов. Как мы можем это сделать?
import matplotlib.dates as mdates
# Plot train and test so you can see where we have split
gdf = x_test[['AllAPIs']] \
.rename(columns={'AllAPIs': 'Test Set'}) \
.join(x_train.rename(columns={'AllAPIs': 'Training Set'}),
how='outer')
ax = gdf.plot(figsize=(12,5),title='API Calls')
plt.xticks(
rotation=45,
horizontalalignment='right',
fontweight='light',
fontsize='medium',
)
plt.show()
Выходной график такой:
Если я добавлю HourLocator следующим образом, я потеряю свои тики:
# set monthly locator
ax.xaxis.set_major_locator(mdates.HourLocator(interval=4))
# set formatter
ax.xaxis.set_major_formatter(mdates.DateFormatter('%Y-%m-%d %H'))
![enter image description here](https://i.stack.imgur.com/vAON1.png)
Чего мне не хватает ?????