[英]How I put same x-axis twice in Bokeh
I want a very large plot on which will be very convinient to have the same axis top and bottom.我想要一个非常大的 plot 在其上具有相同的轴顶部和底部非常方便。 Is there any simple way of duplicating the axis?有没有复制轴的简单方法? Or I need to define a secondary axis but with the same range (I don´t like this solution because Bokeh computes the range of the axis on its own and I don´t want to re compute them)或者我需要定义一个具有相同范围的辅助轴(我不喜欢这种解决方案,因为 Bokeh 会自行计算轴的范围,我不想重新计算它们)
Thanks!谢谢!
It is easy to add extra axis to a plot in bokeh.在散景中很容易为 plot 添加额外的轴。 You need to import your type of axis, here LinearAxis
is used.您需要导入您的轴类型,这里使用的是LinearAxis
。
If you use p.x_range
and p.y_range
in the definition of your new axes, then they have the same range as the original ones.如果您在新轴的定义中使用p.x_range
和p.y_range
,则它们的范围与原始轴相同。
from bokeh.plotting import figure, show, output_notebook
from bokeh.models import LinearAxis
output_notebook()
# some data
p = figure(width=300, height=300)
p.line(x=[1,2,3], y=[2,3,4])
# exta x axis
p.extra_x_ranges.update({'x_above': p.x_range})
p.add_layout(LinearAxis(x_range_name='x_above'), 'above')
# exta y axis
p.extra_y_ranges.update({'y_right': p.y_range})
p.add_layout(LinearAxis(y_range_name='y_right'), 'right')
show(p)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.