1 回答

TA贡献1805条经验 获得超10个赞
我刚刚为此找到了一种解决方案。
我创建了一个函数来定义我想要的刻度并使用了 FuncFormatter 模块。
def format_func(value, tick_number):
hora = mdates.num2date(value)
teste = mlt['BLC 73.61'][hora]
return ('%d:%d \n %0.1f' % (hora.hour, hora.minute,teste))
def format_func2(value, tick_number):
# find the first value
if tick_number == 0:
return ('hh:mm \n MLT ')
else:
return (' ')
首先将时间戳值转换为数字:
xx = [mdates.date2num(i) for i in ada[ini:end].index]
和情节
fig = plt.figure(figsize=(10, 5)) #
ax1 = fig.add_subplot(111)
ax1.plot(xx,ada['BLC 73.61'][ini:end])
# set the major locator ion the month values
ax1.xaxis.set_major_locator(mdates.MonthLocator(interval=5))
# use the format difeined in format_func2
ax1.xaxis.set_major_formatter(plt.FuncFormatter(format_func2))
ax1.xaxis.set_minor_locator(mdates.HourLocator(interval=2))
ax1.xaxis.set_minor_formatter(plt.FuncFormatter(format_func))
添加回答
举报