Datetime 博克:如何及时修复x轴

Datetime 博克:如何及时修复x轴,datetime,axis,bokeh,Datetime,Axis,Bokeh,我在bokeh制作了一个时间序列散点图,当用户以交互方式选择一个新的时间序列时,该散点图会更新。但是,我想将x轴固定在0000到2359小时之间进行比较(Bokeh尝试猜测适当的x范围) 下面是一段随机的数据片段。在这段代码中,如何在不将刻度更改为微秒的情况下修复x_范围 import pandas as pd from bokeh.io import push_notebook, show, output_notebook from bokeh.plotting import figure f

我在bokeh制作了一个时间序列散点图,当用户以交互方式选择一个新的时间序列时,该散点图会更新。但是,我想将x轴固定在0000到2359小时之间进行比较(Bokeh尝试猜测适当的x范围)

下面是一段随机的数据片段。在这段代码中,如何在不将刻度更改为微秒的情况下修复x_范围

import pandas as pd
from bokeh.io import push_notebook, show, output_notebook
from bokeh.plotting import figure
from bokeh.models import Range1d
output_notebook()

data = {'2015-08-20 13:39:46': [-0.02813796,  0],
 '2015-08-28 12:6:5': [ 1.32426938,  1],
 '2015-08-28 13:42:59': [-0.16289655,  1],
 '2015-12-14 16:19:44': [ 2.30476287,  1],
 '2016-02-01 17:8:32': [ 0.41165004,  0],
 '2016-02-09 11:26:33': [-0.65023149,  0],
 '2016-04-08 17:57:47': [ 0.09335096,  1],
 '2016-04-27 19:2:15': [ 1.43917208,  0]}

test = pd.DataFrame(data=data).T
test.columns = ["activity","objectID"]
test.index = pd.to_datetime(test.index)

p = figure(plot_width=500, plot_height=250, x_axis_label='X',    y_axis_label='Y', x_axis_type="datetime")# x_range = Range1d(# dont know what to put here))
r = p.circle(x=test.index.time, y=test["activity"])
show(p, notebook_handle=True);
我已经找到了一个解决方案,但它不能完全固定轴的大小,因为轴的大小似乎取决于其他轴的属性,例如y记号标签的长度

# a method for setting constant x-axis in hours for bokeh:

day_x_axis = pd.DataFrame(data=[0,0], index=['2015-07-28 23:59:00', '2015-08-    28 00:01:00'], columns=["activity"]) 
day_x_axis.index = pd.to_datetime(day_x_axis.index)
new_time_series = pd.concat((old_time_series, day_x_axis), axis=0) # this will set all other columns you had to NaN.
我完全通过在实例化figure对象时设置y_range属性来固定轴