小编rev*_*man的帖子

为什么Bokeh在这里不产生额外的y范围?

我的Bokeh版本是0.12.13和Python 3.6.0,我修改了此处的示例代码:

https://docs.bokeh.org/en/latest/docs/user_guide/plotting.html

我刚刚尝试添加一个额外的y范围。

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

x = [1,2,3,4,5]
y = [1,2,3,4,5]
y2 = [10,9,8,7,6]
y3 = [23,24,25,26,27]

output_file("twin_axis.html")

p = figure(x_range=(0,6), y_range=(0,6))

p.circle(x, y, color="red")

p.extra_y_ranges = {"foo1": Range1d(start=0, end=11)}
p.circle(x, y2, color="blue", y_range_name="foo1")
p.add_layout(LinearAxis(y_range_name="foo1"), 'left')

p.extra_y_ranges = {"foo2": Range1d(start=21, end=31)}
p.circle(x, y3, color="green", y_range_name="foo2")
p.add_layout(LinearAxis(y_range_name="foo2"), 'right')

p.toolbar_location ="above"
show(p)
Run Code Online (Sandbox Code Playgroud)

虽然原始代码运行良好,但我修改后的代码却没有。我无法弄清楚自己在做什么错。我对bokeh有点陌生,所以请向正确的方向引导。编辑:当我添加第三个y轴时没有输出。但是它只能在左侧使用2个轴。

python charts plot multiple-axes bokeh

1
推荐指数
1
解决办法
1126
查看次数

标签 统计

bokeh ×1

charts ×1

multiple-axes ×1

plot ×1

python ×1