Bainly
Bainly

Reputation: 87

How do I add multi-line x-axis labels in Bokeh?

I've made the following box plot chart: https://i.sstatic.net/B0y0I.png

As you can see the x-axis labels overlap. How can I add line breaks to the labels?

I've tried to add the new line character in the actual strings like this:

xlab = [
    'Survey of Professional Forecasters -\nPCE Inflation Nowcast: 2019Q3', 
    'Survey of Professional Forecasters -\nPCE Inflation 1 Year Forecast: 2019Q3',
    'TIPS Spread'
    ]

But it doesn't change anything. I could just increase the size of the x-axis or use shorter labels but I'd rather just use line breaks tbh.

Upvotes: 1

Views: 350

Answers (1)

bigreddot
bigreddot

Reputation: 34568

As of version 1.3.4, multi-line axis labels are still an open issue. For now you can rotate the labels:

p.xaxis.major_label_orientation = pi/4

Upvotes: 1

Related Questions