将多个地块散布成网格图

问题描述 投票:0回答:1

我能够生成/显示单个图,但似乎无法将多个图聚合到一个网格图中。我在做什么错,谢谢?

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
python bokeh
1个回答
0
投票

gridplot接受一个列表列表(一个行列表),而不是一个一维列表。 (或者,如果您确实需要,它确实需要一个一维列表,但是您必须在通话中指定gridplot。)

© www.soinside.com 2019 - 2024. All rights reserved.