我有问题调整日期时间以更好的方式在我的图表中可视化。这是我的代码:
fig = plt.figure()
new.plot(title='(Graph)',figsize=(10,7), legend=None)
plt.tick_params(axis="both", which="both", bottom="off", top="off",
labelbottom="on", left="off", right="off", labelleft="on")
plt.legend(loc='center left', bbox_to_anchor=(1, 0.5), frameon=False)
ax = plt.subplot(111)
ax.spines["top"].set_visible(False)
ax.spines["bottom"].set_visible(True)
ax.spines["right"].set_visible(False)
ax.spines["left"].set_visible(False)
ax.get_xaxis().tick_bottom()
ax.get_yaxis().tick_left()
ax.xaxis.set_major_formatter(mdates.DateFormatter('%Y-%m-%d'))
pp.savefig(bbox_inches='tight')
pp.close()
我试图添加这个库并在ax提名中:
import numpy as np
import matplotlib.pyplot as plt
import matplotlib.dates as mdates
import datetime
xfmt = mdates.DateFormatter('%Y-%m-%d %H:%M:%S')
ax.xaxis.set_major_formatter(xfmt)
您可以尝试旋转标签添加参数qazxsw poi qazxsw poi:
labelrotation