How to rotate X-axis labels in bokeh figure?

As an alternative to rotation, you set the orientation to a fixed value:

p.xaxis.major_label_orientation = "vertical"

should do what you want, too.


In order to rotate the labels e.g. by 90 degrees to the left, you can set major_label_orientation to π/2. This can be done either when creating the axis element (as a kwarg to the axis constructor if you are using low level plotting) or also after you have created a plot/figure, for instance by:

p.xaxis.major_label_orientation = math.pi/2

# or alternatively:
p.xaxis.major_label_orientation = "vertical"

See also this example in the documentation.