🚀 Gen 5 of the leading AI app deployment platform launches October 6. Click for the livestream.

How can I resize labels which are very long

I am creating a chart in python/Jupyter notebook

data = [
go.Bar(
y=[‘Apples’, ‘Oranges’, ‘WatermelonWatermelonWatermelonWatermelonWatermelonWatermelonWatermelon’, ‘Pears’],
x=[3, 2, 1, 4], orientation=‘h’
)
]

offline.iplot(data)

How can I display the string ‘Watermelonwater…’ I want to display the entire string - it’s fine if it is wrapped.

You can increase the left margin to show long label.

layout = go.Layout(
    margin=go.layout.Margin(
        l=500
    )
)

fig = go.Figure(data=data, layout=layout)
plotly.offline.iplot(fig, filename='basic-bar')
1 Like

Do you know if I can wrap text?

It also seems like the text should be truncated on the right. It is now truncated on the left.

Hi @nilanjenator, you can, and also you can adjust the margin, for example:

data = [
   go.Bar(
       y=['Apples', 'Oranges', 'Watermelon<br>Watermelon<br>Watermelon', 'Pears'],
       x=[3, 2, 1, 4], orientation='h'
   )]

layout = go.Layout(
   margin=go.layout.Margin(
       l=100
   )
)

fig = go.Figure(data=data, layout=layout)
plotly.offline.iplot(fig)

Thanks,
I was actually looking for automatic wrapping of long labels