使用Bokeh可视化TimeSeries - 数据点重叠

时间:2016-01-31 11:05:18

标签: python bokeh

我有一个每个时间点的值(每半小时更新一次)。

我将csv中的数据读入pandas数据帧:

import pandas as pd
headers = ['timestamp', 'pressure']
df = pd.read_csv('data.csv', header=None, names=headers)

数据类型为:

timestamp    object
pressure      int64

df本身看起来像这样:

             timestamp  pressure
0  2016-01-29 10:00:00         3
1  2016-01-30 22:30:00         2
2  2016-01-31 04:30:00         1

我想象它如下:

fig = TimeSeries(df, x = 'timestamp', y = 'pressure',builder_type='point'
                                                    ,xscale="datetime")

它返回的是:

enter image description here

但是,如果我删除时间部分 - 它将正常工作:

enter image description here

我做错了什么?

1 个答案:

答案 0 :(得分:1)

尝试设置webgl = False。

Bokeh 0.10中的webgl中有一个issue,当绘图放大时会导致跳跃数据点。它与渲染的舍入误差有关。我怀疑当前的行为与此有关,而且问题并没有完全解决。

试试这个最小的例子:

import numpy as np
import bokeh.plotting as bk
from datetime import datetime,timedelta

no_of_datapoints=10

base = datetime(2016, 2, 1, 9, 36, 0)
date_list = [base - timedelta(minutes=x) for x in range(0, no_of_datapoints)]
datapoints=np.arange(no_of_datapoints)

p=bk.figure(webgl=True,x_axis_type="datetime")
p.scatter(x=date_list,y=datapoints)
bk.show(p)

设置webgl = True给出了图表: incorrect diagram when webgl=True

webgl = False给出了图表: correct diagram when webgl=False

相关问题