x轴上的HoloViews VLines,时间限制为秒

时间:2018-08-22 19:36:33

标签: time line bokeh holoviews

以下代码仅以秒的分辨率绘制VLine,即在12:00:01.5的线在12:00:01绘制。当x轴变量包含时间而不是普通浮点数时,是否有某种方法可以以更高分辨率绘制VLine?

import holoviews as hv
import pandas as pd
import tzlocal

hv.notebook_extension('bokeh')

t = [pd.to_datetime('12:00:00')+pd.to_timedelta(t, unit='ms') for t in np.arange(0, 3000, 50)]
x = np.random.rand(len(t))
t_lines = [pd.to_datetime(_).tz_localize('utc').astimezone(tzlocal.get_localzone()).replace(tzinfo=None) for _ in ['12:00:01.5', '12:00:02']]
lines = [hv.VLine(_).options(color='red') for _ in t_lines]
c = hv.Overlay([hv.Curve((t, x)).options(width=600)]+lines)
c

enter image description here

我正在使用散景0.13.0的HoloViews 1.10.7。

0 个答案:

没有答案