Removing the title and the margin of the X and Y axis

Hello,

How do you remove the titles and the margins of the Y and X axis please (in red) ? I would like to expand my graph on their sides.

The code is :

def test_graph():
    import plotly.express as px

    x = [1, 3, 2]
    y = [2, 3, 4]

    data_canada = px.data.gapminder().query("country == 'Canada'")
    fig = px.bar(data_canada, x='year', y='pop')
    fig.update_layout(
          margin=dict(l=0, r=0, t=0, b=0),
    )

    return fig

Thank you.

Hey @BeginnerDash ,

I think you can try :

fig.update_layout(yaxis_title=None)
fig.update_layout(xaxis_title=None)

Have a nice day.

1 Like