Python Bokeh:在同一侧显示多个Y轴的附加Y轴标签
我有一个图表,可以显示多条线,在4个不同的y轴比例上。将第二个y轴添加到边时,仅显示第一个轴的标签。如何显示第二轴标签 例如:Python Bokeh:在同一侧显示多个Y轴的附加Y轴标签,python,graph,bokeh,Python,Graph,Bokeh,我有一个图表,可以显示多条线,在4个不同的y轴比例上。将第二个y轴添加到边时,仅显示第一个轴的标签。如何显示第二轴标签 例如: from bokeh.models import Range1d, LinearAxis from bokeh.plotting import figure from bokeh.io import show, output_notebook output_notebook() fig = figure() # Define x-axis fig.xaxis.ax
from bokeh.models import Range1d, LinearAxis
from bokeh.plotting import figure
from bokeh.io import show, output_notebook
output_notebook()
fig = figure()
# Define x-axis
fig.xaxis.axis_label = 'Date'
# Define 1st LHS y-axis
fig.yaxis.axis_label = 'Pressure [barg]'
fig.y_range = Range1d(start=0, end=200)
# Create 2nd LHS y-axis
fig.extra_y_ranges['temp'] = Range1d(start=0, end=50)
fig.add_layout(LinearAxis(y_range_name='temp', axis_label='Temperature [°C]'), 'left')
# Create 1st RHS y-axis
fig.extra_y_ranges['lflow'] = Range1d(start=0, end=50000)
fig.add_layout(LinearAxis(y_range_name='lflow', axis_label='Liquid Flowrate [bbl/day]'), 'right')
# Create 2nd RHS y-axis
fig.extra_y_ranges['gflow'] = Range1d(start=0, end=50)
fig.add_layout(LinearAxis(y_range_name='gflow', axis_label='Gas Flowrate [MMscf/day]'), 'right')
fig.line(
x = [0,1,2,3,4,5],
y = [80,88,87,70,77,82],
legend = 'Pressure',
color = 'purple'
)
fig.line(
x = [0,1,2,3,4,5],
y = [5,6,5,5,5,4],
legend = 'Temperature',
y_range_name = 'temp',
color = 'red'
)
fig.line(
x = [0,1,2,3,4,5],
y = [10000,10100,10000,10150,9990,10000],
legend = 'Liquid Flowrate',
y_range_name = 'lflow',
color = 'orange'
)
fig.line(
x = [0,1,2,3,4,5],
y = [35,37,40,41,40,36],
legend = 'Gas Flowrate',
y_range_name = 'gflow',
color = 'green'
)
fig.toolbar_location = 'above'
show(fig)
从上面的示例中,仅显示压力和液体流量轴标签。如何显示温度和气体流量轴标签?可能是您的bokeh版本。我目前使用的是bokeh版本0.12.7,您的代码未经修改,结果如下: 对于bokeh版本0.12.9一个解决方法是指定一些较大的
minu border\u left
和minu border\u right
,例如
fig = figure(plot_width=700,min_border_left=150,min_border_right=170)
额外轴标签之间的间距大于正常值:
哦,那很有趣。我使用的是0.12.9版,所以我假设有一个回归。这应该在github repository@NixonInnes中进行注释,添加min_border_left=150,min_border_right=170使标签出现在版本0.12.9上,但标签和轴的间距比正常值大。看我编辑的答案。啊哈!非常感谢,非常感谢。