[英]Python bokeh modify axis scale
How can I modify the y-axis
scale at figures and at charts? 如何修改图形和图表的y-axis
比例? I want something like this: my_figure.y_range.end = my_figure.y_range.end * 1.3
我想要这样的东西: my_figure.y_range.end = my_figure.y_range.end * 1.3
So I want a bit higher y-axis
. 所以我想要更高的y-axis
。 Thank you! 谢谢!
Figure
uses DataRange1d
objects by default, which causes the range to automatically computed. Figure
默认情况下使用DataRange1d
对象,这将自动计算范围。 But this happens on the browser, because it takes into account information like glyph extent that are only available at render time. 但这在浏览器上发生,因为它考虑了仅在渲染时可用的信息,例如字形范围。 The reason that my_figure.y_range.end * 1.3
does not work is because the "automatic" value of end
is not known yet . my_figure.y_range.end * 1.3
不起作用的原因是因为end
的“自动”值尚不清楚 。 It is only set automatically inside the browser. 它仅在浏览器内部自动设置。 You can override the "automatic" behaviour of a DataRange
by supplying start
and end
, but you have to give it an explicit, numeric value that you want, ie: 您可以通过提供start
和end
来覆盖DataRange
的“自动”行为,但是必须给它提供一个所需的显式数字值,即:
my_figure.y_range.end = 10
Alternatively, DataRange1d
models have range_padding
property that you can set, which controls the amount of "extra padding" added to the automatically computed bounds. 另外, DataRange1d
模型具有您可以设置的range_padding
属性,该属性控制添加到自动计算的边界中的“额外填充”的数量。 It is described here: 此处描述:
http://docs.bokeh.org/en/latest/docs/reference/models/ranges.html#bokeh.models.ranges.DataRange1d.range_padding http://docs.bokeh.org/en/latest/docs/reference/models/ranges.html#bokeh.models.ranges.DataRange1d.range_padding
This might accomplish what you want in a different way, but note that it affects both start and end. 这可能会以其他方式完成您想要的操作,但是请注意,它会影响开始和结束。
Finally, if you'd just like to completely control the range, without having auto ranging at all, you can do this when you create the figure: 最后,如果您只想完全控制范围,而根本没有自动范围,则可以在创建图形时执行以下操作:
p = figure(..., x_range=(10, 20))
This will create a fixed Range1d
for the x-axis with start=10
and end=20
. 这将为x轴以start=10
和end=20
创建一个固定的Range1d
。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.