Make The Bar Chart Text Go Down A Line

I have the next graph:
Screenshot 2022-04-02 151808
Example:
VODKA 80 PROOF - will become
VODKA
80
PROOF
I would like the have each word on its own line one under another.
I can’t find anything on the internet, tried playing a bit with the CSS but couldn’t figure it out.

Hello @Matan

It seems that there is still no solution, please take a look at this thread.

hmm…
It’s been 6 years, I will leave the question open hoping maybe someone has an answer,
but I gotta say it’s actually a pretty important option to have so hopefully someone from the dash development team will see this post and maybe look into it. :slight_smile:

Hi @Matan,

Plotly figures support markdown syntax <br> for line breaks, below is a workaround with using custom ticktext on axis.

import plotly.express as px

x = ['long label', 'very long label', 'extra super long label']
y= [10,50,15]

x_labels=[]
for label in x:
    x_labels.append(label.replace(' ','<br>'))
    
print(x_labels)

fig = px.bar(x=x, y=y)
fig.update_xaxes(tickvals=x, ticktext=x_labels)
fig.show()

2 Likes

AMAZING! thank you very much!

1 Like