Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to change the text orientation of stacked bar chart created with Plotly Express?

I am completely new to data visualisation with Plotly. I've created a stacked bar chart with text labels, but the single-digit value have rotated automatically. How can I make all texts shown without being rotated?

fig = px.bar(
    data_stack,
    y = "newform",
    x = "percentage",
    color = "Qcat",
    barmode = "stack",
    text = "size",
    orientation = "h")

Here's a screenshot for reference:

enter image description here

like image 895
Quinn Chan Avatar asked Dec 14 '25 10:12

Quinn Chan


1 Answers

fig.update_traces(textangle=0)
like image 106
tzinie Avatar answered Dec 15 '25 22:12

tzinie



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!