将多个图散景成网格图
bokeh multiple plots into a gridplot
我能够 generate/show 单独的图,但似乎无法将多个图聚合成一个网格图。我做错了什么,谢谢?
g = []
for item in basket:
# sourcing and processing my data streams here
# then moving to plotting the processed data into a single plot as below
TOOLTIPS = [("(x,y)", "($x, $y)")]
p = figure(tools="pan,box_zoom,reset,save",
title=TITLE,x_range=x,
y_range=(<<my_y0_range_1>>,<<my_y0_range_2>>),
x_axis_label='time',y_axis_label='index',
plot_width=1000, plot_height=450,toolbar_location="below",
tooltips=TOOLTIPS)
p.background_fill_color = <<mycolor>>
p.line(x, y0, legend_label="values", line_width=1)
p.extra_y_ranges = {"Vol": Range1d(start=<<my_y1_range_1>>,end=<<my_y1_range_2>>)}
p.line(x, y1, legend_label="my 2nd Y axis", line_color="red",y_range_name="Vol")
p.varea(x=x,y1=<<my_range_1>>,y2=<<my_range_2>>,alpha=0.3)
p.add_layout(LinearAxis(y_range_name="Vol"), 'right')
#show(p) <-- this works and displays the individual plot
g.append(p)
# end/exit my for loop here
print (len(g)) <-- this prints out 3 in my test case
print (g) <-- [Figure(id='1001', ...), Figure(id='1066', ...), Figure(id='1131', ...)]
grid = gridplot(g) <-- complains here
我收到的确切错误消息是..
grid = gridplot(g)
File "\Python\Python35\lib\site-packages\bokeh\layouts.py", line 304, in gridplot
for x, item in enumerate(row):
TypeError: 'Figure' object is not iterable
gridplot
采用列表列表(行列表),而不是单个 1d 列表。 (或者如果你真的想要,它确实需要一个一维列表,但你必须在调用中指定 ncols
。)
我能够 generate/show 单独的图,但似乎无法将多个图聚合成一个网格图。我做错了什么,谢谢?
g = []
for item in basket:
# sourcing and processing my data streams here
# then moving to plotting the processed data into a single plot as below
TOOLTIPS = [("(x,y)", "($x, $y)")]
p = figure(tools="pan,box_zoom,reset,save",
title=TITLE,x_range=x,
y_range=(<<my_y0_range_1>>,<<my_y0_range_2>>),
x_axis_label='time',y_axis_label='index',
plot_width=1000, plot_height=450,toolbar_location="below",
tooltips=TOOLTIPS)
p.background_fill_color = <<mycolor>>
p.line(x, y0, legend_label="values", line_width=1)
p.extra_y_ranges = {"Vol": Range1d(start=<<my_y1_range_1>>,end=<<my_y1_range_2>>)}
p.line(x, y1, legend_label="my 2nd Y axis", line_color="red",y_range_name="Vol")
p.varea(x=x,y1=<<my_range_1>>,y2=<<my_range_2>>,alpha=0.3)
p.add_layout(LinearAxis(y_range_name="Vol"), 'right')
#show(p) <-- this works and displays the individual plot
g.append(p)
# end/exit my for loop here
print (len(g)) <-- this prints out 3 in my test case
print (g) <-- [Figure(id='1001', ...), Figure(id='1066', ...), Figure(id='1131', ...)]
grid = gridplot(g) <-- complains here
我收到的确切错误消息是..
grid = gridplot(g)
File "\Python\Python35\lib\site-packages\bokeh\layouts.py", line 304, in gridplot
for x, item in enumerate(row):
TypeError: 'Figure' object is not iterable
gridplot
采用列表列表(行列表),而不是单个 1d 列表。 (或者如果你真的想要,它确实需要一个一维列表,但你必须在调用中指定 ncols
。)