Denys
Denys

Reputation: 4557

Visualizing TimeSeries with Bokeh - datapoints overlap

I have a value for each point in time (updated each half an hour).

I read the data from csv into a pandas dataframe :

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

The data types are:

timestamp    object
pressure      int64

The df itself looks like this:

             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

I visualize it like following:

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

And what it returns is:

enter image description here

However, if i remove the time part - it will work fine:

enter image description here

What am i doing wrong?

Upvotes: 0

Views: 672

Answers (1)

Anadyn
Anadyn

Reputation: 81

Try setting webgl=False.

There was an issue in webgl in Bokeh 0.10 causing jumping datapoints when the plot was zoomed in. It had to do with round-off errors with the rendering. I suspect that the current behaviour is related to this, and that problems are not quite sorted out.

Try this minimal example:

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)

Setting webgl=True gives the diagram: incorrect diagram when webgl=True

webgl=False gives the diagram: correct diagram when webgl=False

Upvotes: 1

Related Questions