我想要的是非常直接的,我只希望定位器滴答声从指定的时间戳开始:peudo code: locator.set_start_ticking_at( datetime_dummy )
到目前为止我没有找到任何东西。在
下面是这个问题的代码部分:
axes[0].set_xlim(datetime_dummy) # datetime_dummy = '2015-12-25 05:34:00'
import matplotlib.dates as matdates
seclocator = matdates.SecondLocator(interval=20)
minlocator = matdates.MinuteLocator(interval=1)
hourlocator = matdates.HourLocator(interval=12)
seclocator.MAXTICKS = 40000
minlocator.MAXTICKS = 40000
hourlocator.MAXTICKS = 40000
majorFmt = matdates.DateFormatter('%Y-%m-%d, %H:%M:%S')
minorFmt = matdates.DateFormatter('%H:%M:%S')
axes[0].xaxis.set_major_locator(minlocator)
axes[0].xaxis.set_major_formatter(majorFmt)
plt.setp(axes[0].xaxis.get_majorticklabels(), rotation=90 )
axes[0].xaxis.set_minor_locator(seclocator)
axes[0].xaxis.set_minor_formatter(minorFmt)
plt.setp(axes[0].xaxis.get_minorticklabels(), rotation=90 )
# other codes
# save fig as a picture
上面代码的x轴刻度将得到:
如何告诉次要定位器与主定位器对齐?
如何告诉定位器从哪个时间戳开始计时?在
我所做的:set_xlim
无法做到这一点seclocator.tick_values(datetime_dummy, datetime_dummy1)
什么都不做
不要使用} 和^{} 精确指定要标记的秒数和分钟数。}参数用于构造dateutil rrule。
interval
关键字参数,而是使用^{bysecond
和{rrule
生成与特定模式(或者可以说是“规则”)匹配的日期时间。在例如,
bysecond=[20, 40]
将日期时间限制在那些 等于20或40。因此,下面的小刻度线只出现在日期时间上 他们的分数等于20或40。在@unutbu:多谢了:我到处找相关问题的答案!在
@eliu:我改编了unutbu的优秀答案来演示如何定义列表(创建不同的“dateutil”规则),让您完全控制显示哪些x记号。试着依次取消对下面每个示例的注释,并使用这些值来查看效果。希望这有帮助。在
相关问题 更多 >
编程相关推荐