Ability to rotate the y-axis title in bokeh

I am trying to rotate the axis tittle of the yaxis of a bokeh figure. I cannot seem to find an option for this. Happy if anyone got a solution. I am actually in need to have this workig into holoviews/hvplot using the bokeh backend, but have not found a way supporting this.

What have you tried that did NOT work as expected?
I have tried to modify the major_label_orientation, but that is the labels for the major ticks.

Code example for jupyter notebook:

# Imports
import bokeh
import pandas as pd
import numpy as np
from bokeh.plotting import figure, ColumnDataSource, show, output_notebook

# Create dummy data
xs = np.linspace(10,20, 11)
ys = np.random.random(len(xs)).cumsum()

data = {
    'x': xs, 
    'y': ys
df = pd.DataFrame(data)
source = ColumnDataSource(df)

# Make plot
p = figure(frame_height=40, width=700)
p.line(x='x', y='y', line_width=2, source=source)
p.yaxis.axis_label = 'long label that would like to be rotated'


In some cases, a screenshot of your plot will also be helpful.
If I have a long axis title I have issues fitting it. Would be nice if possible to rotate or wrap it.

Searching for an option like ‘p.yaxis.axis_label_orientation’

Happy to learn a good trick on this.

Bokeh axis labels do not support rotation, they are always parallel to their axis. You could put a Div to the left of the plot, and use that as a kind of axis label.

Thanks @Bryan I will add an issue for this as it has been a reappearing need both to rotate x axis labels vertically (if I have a slim vertically elongated plots) as well as to rotate yaxis labels horizontally if I have slim laterally elongated plots with long label names.

I just added this issue. Hope the suggestion could be seen as something that could serve more people and thus maybe be added in time.

1 Like

Developers have swiftly added this feature, see pull request 13044, thanks a lot to those involved!
Setting this as solved given the enhancement.

1 Like