3

I have a graph which is to display multiple lines, on 4 different y-axis scales. When I add a second y-axis to a side, only the label of the first axis is displayed. How can I have the 2nd axis label be shown?

Example:

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) 

Example Graph

From the example above, only the Pressure and Liquid Flowrate axis labels are displayed. How can I make the Temperature and Gas Flowrate axis labels display?

1 Answer 1

1

It might be your bokeh version. I am currently using bokeh version 0.12.7 and your code without modifications and the result is as follows: enter image description here

For bokeh version 0.12.9 a workaround is to specify some large min_border_left and min_border_right, e.g.

fig = figure(plot_width=700,min_border_left=150,min_border_right=170) 

The separation between the labels of the extra axes is larger than normal:

enter image description here

Sign up to request clarification or add additional context in comments.

4 Comments

Oh, that's interesting. I'm using version 0.12.9
So I assume there has been a regression. This should be commented in the github repository github.com/bokeh/bokeh
@NixonInnes, adding min_border_left=150,min_border_right=170 made the labels appear on version 0.12.9, but the separation of label and axis is larger than normal. See my edited answer.
Ah ha! Thanks so much, its greatly appreciated.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.