散景显示从一开始就放大的图

jf3*_*328 3 python bokeh

假设我绘制了 50 年的数据

import pandas as pd
from bokeh.charts import TimeSeries
df = pd.util.testing.makeTimeDataFrame(12500)
p = TimeSeries(df, tools = 'xwheel_zoom,reset')
Run Code Online (Sandbox Code Playgroud)

当我打开html文件时,它显示整个数据,然后我可以放大。有没有办法指定当我打开html文件时,它只显示去年的数据?

jsi*_*ell 5

您可以按照文档中的说明设置 x_range

这将决定初始缩放。如果像文档中的修改示例那样缩小,则仍将绘制其余数据:

from bokeh.plotting import figure, output_file, show
from bokeh.models import Range1d

output_file("title.html")

# create a new plot with a range set with a tuple
p = figure(plot_width=400, plot_height=400, x_range=(0, 20))

# set a range using a Range1d
p.y_range = Range1d(0, 15)

p.circle([1, 2, 3, 4, 5, 25], [2, 5, 8, 2, 7, 50], size=10)

show(p)
Run Code Online (Sandbox Code Playgroud)