Plot bokeh如何使列数据源列使用第二个Y轴进行显示

Plot bokeh如何使列数据源列使用第二个Y轴进行显示,plot,bokeh,Plot,Bokeh,我使用VBar字形以Bokeh显示条形图,数据通过ColumnDataSource流式传输到它。此外,我想在从其中一列打印数据时添加不同的y轴 因此,代码如下: self.bar_text = ["V1, "V2", "V3"] self.plot = figure(x_range=FactorRange(*self.bar_text), y_range=[0, 150]) # Now I add an extra y-axes which is displayed correctly self

我使用
VBar
字形以Bokeh显示条形图,数据通过
ColumnDataSource
流式传输到它。此外,我想在从其中一列打印数据时添加不同的y轴

因此,代码如下:

self.bar_text = ["V1, "V2", "V3"]
self.plot = figure(x_range=FactorRange(*self.bar_text), y_range=[0, 150])
# Now I add an extra y-axes which is displayed correctly
self.plot.extra_y_ranges = {"delay": Range1d(start=0, end=25)}
self.plot.add_layout(LinearAxis(y_range_name="delay"), 'right')

# The data will be fed to the graph via th column data source
self.input_sources = ColumnDataSource(dict(x=[], top=[], color=[]))
self.bar_glyph = VBar(x="x", top="top", bottom=0, width=0.2, fill_color="color")
self.plot.add_glyph(self.input_sources, self.bar_glyph) 
我可以通过以下方式将数据提供给此:

obj.input_sources.stream(dict(x=['V1', 'V2', "V3"],
                                 top=[30, 50, 10],
                                 color=["blue", "blue", "red"]), 3)

但是,我不确定如何将最后一列
V3
与第二个附加y轴相关联。

好的,我找到了。答案是为它们使用单独的数据源和图示符,并将它们分配到正确的
y\u范围

self.left_input_sources = ColumnDataSource(dict(x=[], top=[], color=[]))
self.right_input_sources = ColumnDataSource(dict(x=[], top=[], color=[]))
self.left_bar_glyph = VBar(x="x", top="top", bottom=0, width=0.2, fill_color="color")
self.right_bar_glyph = VBar(x="x", top="top", bottom=0, width=0.2, fill_color="color")
self.plot.add_glyph(self.left_input_sources, self.left_bar_glyph)  # Use default y-axes
self.plot.add_glyph(self.right_input_sources, self.right_bar_glyph, y_range_name='delay')