Skip to content

Does plotly allow for multiple lines in the xaxis labels? #2858

@anurag0511

Description

@anurag0511

Here, I am trying to plot a bar chart and in the case there is a really long label, the plotly figure resizes itself an changes the angle of the labels.
What I want is this:
image

I can get this by adding a <br> in the label, however, I am unable to generate this despite adjusting the parameters like ticklen, tickwidth and setting automargin. The plot I am getting looks like this.
image

There are more solutions regarding adjustment of margin, however I am still unable to get the label in two lines. Is there any documentation that could point me towards the solution?
I have attached the snippet here.

x1 = ['A very long sentence that needs broken up fhasfb asfasfz cas wfwfer wrwnflf fwerf', 'Regular Length', "Cory", "Dave"]

y1 = [20, 30, 25, 40]

fig = go.Figure()

fig.add_trace(go.Bar(x=x1, y=y1))
fig.update_layout(
	xaxis={
	'ticklen' : 4,
	'automargin': True,
	'tickwidth' : 1.2}
)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions