在Python中使用bokeh:timeseries

在Python中使用bokeh:timeseries,python,bokeh,Python,Bokeh,我试图在bokeh和放大x轴以缩放时创建一个带有条形图的绘图。我有点不知道怎么做。我正在使用以下代码: import datetime import time import numpy as np import pandas as pd from bokeh.plotting import * from bokeh.models import Range1d def GenerateTimeSeries(StartTime,points): valuesStart = [int(c)

我试图在bokeh和放大x轴以缩放时创建一个带有条形图的绘图。我有点不知道怎么做。我正在使用以下代码:

import datetime
import time
import numpy as np
import pandas as pd
from bokeh.plotting import *
from bokeh.models import Range1d

def GenerateTimeSeries(StartTime,points):
    valuesStart = [int(c) for c in StartTime.split('-')]
    startT = datetime.datetime(valuesStart[0], valuesStart[1], valuesStart[2], valuesStart[3], valuesStart[4])
    start = time.mktime(startT.timetuple())
    dt =24*3600
    Time = np.linspace(start,start + points*dt, points) * 1000  
    R= np.random.choice(range(0,255),len(Time))
    TimeSeries = pd.DataFrame({'R': R,'time':Time})
    return TimeSeries


timeSeries = GenerateTimeSeries('2015-12-21-0-0',100)
TOOLS = 'xpan,xwheel_zoom'#TOOLS = 'box_select,crosshair,resize,reset'
output_file('Figure.html',title = 'Title')        
p= figure(title = 'Title',x_axis_label='time',plot_width=800,plot_height=500,x_range=Range1d(timeSeries.time[0],timeSeries.time[10]),y_range=Range1d(0,300),tools=TOOLS,x_axis_type = "datetime")#
如何制作
GenerateTimeSeries
函数的“灵感”来自bokeh文档的以下链接:

现在,如果使用
绘图,结果似乎正常:

p.line(timeSeries.time, timeSeries.R, color='#1F78B4', legend='ACME')
show(p)
但是使用
rect
时:

p.rect(x=timeSeries.time[i],y=256/2,width=100,height=256,color='#1F78B4',alpha=0.4)# I want the bar to have a constant height, in case you are wondering why I have the `y` constant.
show(p)

rect
中的结果是一些宽度非常小、彼此之间距离非常大的条。如何缩放以使条形图彼此接近?

我认为错误在于以下几行:

p.rect(x=timeSeries.time[i],y=256/2,width=100,height=256,color='#1F78B4',alpha=0.4)
因为宽度为100(在x坐标系中)意味着100秒(不是像素)。所以这个结果只是整个x_范围的一小部分

dt =24*3600
Time = np.linspace(start,start + points*dt, points) * 1000