How to hide legend with Plotly Express and Plotly

After creating the figure in plotly, to disable the legend you can make use of this command:

fig.update_layout(showlegend=False)

For Advanced users:
You can also enable/disable the legend for individual traces in a figure by setting the showlegend property of each trace. For instance:

fig.add_trace(go.Scatter(
    x=[1, 2],
    y=[1, 2],
    showlegend=False))

You can view the examples here: https://plotly.com/python/legend/

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)