Is there a way to adjust automatically the title of a graph?

Is there a way to automatically adjust the title of a graph to its margins ?

As you can see here my title is overflowing on the margin, is there a property to adjust it automatically ?

title

My code is :

fig = make_subplots(
    # shared_yaxes=False,
    # horizontal_spacing=0,
)

fig.add_trace(
    go.Bar(
        x=...
        orientation='h',
        y=...
        text=...
    )
),

fig.update_layout(
    barmode='stack',
    margin=dict(l=0, r=0, t=25, b=0),
    xaxis_title=None,
    yaxis_title=None,
    showlegend=False,
    uniformtext_minsize=20,
    uniformtext_mode='show',
    bargap=0.1,
    title_text="Nombre de Glass Attach"
),

fig.update_traces(
    textfont_size=20,
    textposition='auto',
),

Thank you :slight_smile:

Hey @BeginnerDash ,

Have you tinkered with title_y value ?

fig.update_layout(title_y=<VALUE>)

Thank you, I tried other proprieties but nothing worked this one set to 1 is perfect :slight_smile:

1 Like