假设我绘制了 50 年的数据
import pandas as pd
from bokeh.charts import TimeSeries
df = pd.util.testing.makeTimeDataFrame(12500)
p = TimeSeries(df, tools = 'xwheel_zoom,reset')
当我打开html文件时,它会显示整个数据,然后我可以放大。有没有办法指定当我打开html文件时,它只显示去年的数据?
最佳答案
您可以按照说明设置 x_range in the docs
这将决定初始缩放。如果像文档中的修改示例那样缩小,则仍会绘制其余数据:
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)
关于python - Bokeh 显示从一开始就放大的图,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42279948/