【发布时间】:2021-07-06 13:58:33
【问题描述】:
我一直试图在 x 轴上设置一个次要的 DateTime 间隔,但它根本不显示。我在 google collabnote book 上这样做。在重新运行之前我能够让它工作,它似乎产生了与正确情节相去甚远的不同结果。任何建议都会很棒,提前谢谢你。
import matplotlib.pyplot as plt
import matplotlib.dates as mdates
plt.style.use("dark_background")
eurusd['Close'] = pd.to_numeric(eurusd['Close'])
plt.figure(figsize=(40,10))
plt.xticks(rotation= 90)
ax = plt.gca()
xfmt = mdates.DateFormatter('%Y-%m-%d %H:%M:%S')
hours= mdates.HourLocator(interval=180)
ax.xaxis.set_major_formatter(xfmt)
ax.xaxis.set_major_locator(mdates.HourLocator(interval=720))
#issues with the minor locator not reflecting on plot
ax.xaxis.set_minor_locator(hours)
ax.spines['bottom'].set_linewidth(0.5)
plt.plot(eurusd['Local time'],eurusd['Close'],color='yellow', linewidth=1.5)
【问题讨论】:
标签: python pandas matplotlib google-colaboratory