[英]How to set fixed yaxis bounds in bokeh?
I would like to have a fixed Y-axis, with a minimum of -0.2 and a maximum of 0.5. 我想有一个固定的Y轴,最小值为-0.2,最大值为0.5。 I tried things like: 我尝试过类似的事情:
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)
But if the max y value in my dataset is 0.3, the y axis won't go higher and stop at 0.3. 但是,如果我的数据集中的最大y值为0.3,则y轴不会更高并停在0.3。
How can I fix the bounds? 如何解决界限?
Ok I solved my problem, apparently the options I tried don't apply to a bar chart generated with the Bar()
function. 好的,我解决了我的问题,显然我尝试的选项不适用于由Bar()
函数生成的Bar()
。
Here is my solution: 这是我的解决方案:
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)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.