程序问答   发布时间:2022-06-01  发布网站:大佬教程  code.js-code.com
大佬教程收集整理的这篇文章主要介绍了mathplotlib set_minor_locator 不起作用大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。

如何解决mathplotlib set_minor_locator 不起作用?

开发过程中遇到mathplotlib set_minor_locator 不起作用的问题如何解决?下面主要结合日常开发的经验,给出你关于mathplotlib set_minor_locator 不起作用的解决方法建议,希望对你解决mathplotlib set_minor_locator 不起作用有所启发或帮助;

我一直试图在 x 轴上设置一个较小的 datetiR_804_11845@e 间隔,但它根本没有显示。我在 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)

mathplotlib set_minor_locator 不起作用

解决方法

小调音阶的设置方式必须与大调音阶相同。

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=(20,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_formatter(xfmt)
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)

plt.setp(ax.xaxis.get_majorticklabels(),rotation=45)
plt.setp(ax.xaxis.get_minorticklabels(),rotation=45)
plt.show()

mathplotlib set_minor_locator 不起作用

大佬总结

以上是大佬教程为你收集整理的mathplotlib set_minor_locator 不起作用全部内容,希望文章能够帮你解决mathplotlib set_minor_locator 不起作用所遇到的程序开发问题。

如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。

本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。