如何在散景中设置固定的 yaxis 边界?
How to set fixed yaxis bounds in bokeh?
我想要一个固定的 Y 轴,最小值为 -0.2,最大值为 0.5。
我试过类似的东西:
p = Bar(data, 'key_0', values='values', y_range=(-0.2, 0.5))
p.yaxis[0].ticker=FixedTicker(ticks=[-0.2, 0, 0.2, 0.5])
p.yaxis.bounds = (-0.2, 0.5)
但是如果我数据集中的最大y值是0.3,y轴不会变高而停在0.3。
如何修正边界?
好的,我解决了我的问题,显然我尝试的选项不适用于使用 Bar()
函数生成的条形图。
这是我的解决方案:
p= figure(plot_width=900, plot_height=400, y_range=(-0.2, 0.5))
# setting bar values
h = values
# Correcting the bottom position of the bars to be on the 0 line.
adj_h = h/2
# add bar renderer
p.rect(x=x, y=adj_h, width=0.8 , height=h)
我想要一个固定的 Y 轴,最小值为 -0.2,最大值为 0.5。 我试过类似的东西:
p = Bar(data, 'key_0', values='values', y_range=(-0.2, 0.5))
p.yaxis[0].ticker=FixedTicker(ticks=[-0.2, 0, 0.2, 0.5])
p.yaxis.bounds = (-0.2, 0.5)
但是如果我数据集中的最大y值是0.3,y轴不会变高而停在0.3。
如何修正边界?
好的,我解决了我的问题,显然我尝试的选项不适用于使用 Bar()
函数生成的条形图。
这是我的解决方案:
p= figure(plot_width=900, plot_height=400, y_range=(-0.2, 0.5))
# setting bar values
h = values
# Correcting the bottom position of the bars to be on the 0 line.
adj_h = h/2
# add bar renderer
p.rect(x=x, y=adj_h, width=0.8 , height=h)