我有一个问题,我在bokeh绘制的日期时间点偏离/偏移了4个小时。我运行的是Bokeh0.12.4、Python2.7.12、Windows7。在
在bokeh github上报告了同样的问题,但表示应该在那里解决。还有一个关于1小时前关闭的SO post,但是发布在那里的解决方案似乎不适用于Windows。有人知道如何解决这个问题吗?
我的示例将两个字符串转换为datetime对象,然后尝试在bokeh中绘制它们。我使用的是字符串,因为我最终计划从SQLite数据库中提取这些数据,而datetime库是因为我已经使用了它作为我的主代码(不想为此引入numpy)。在
我的例子试图在08:00和15:00绘制数据,但是它们却提前了4h;分别是12:00和19:00。在
import datetime as dt
from bokeh.plotting import figure, output_file, show
def plotTheData(xvals, yvals, filename="datetime.html", title="boom!"):
output_file(filename, title=title)
p = figure(width=800, height=500, x_axis_type="datetime")
p.circle(xvals, yvals, size=6)
show(p)
if __name__ == '__main__':
datetimes = [
dt.datetime.strptime("2017-03-30 15:00:05","%Y-%m-%d %H:%M:%S"),
dt.datetime.strptime("2017-03-30 08:00:05","%Y-%m-%d %H:%M:%S")
]
doorstates = [0,1]
plotTheData(datetimes,doorstates)
for r in zip(datetimes, doorstates):
print r
print r[0].strftime("%Y-%m-%d %H:%M:%S"), r[1]
输出
^{pr2}$
目前没有回答
相关问题 更多 >
编程相关推荐