Skip to content Skip to sidebar Skip to footer

Plotly: Turn Off Modebar For The Session

I can turn off the modebar in plotly by passing displayModeBar: False as the value of config in fig.show(), like this- import plotly.express as px df = px.data.stocks() fig = px.l

Solution 1:

As of writing this there isn't an official way to set a default config value for the show function of every figure.

What I would recommend as a workaround is to create a function that sets default values and passes them on to the show function of a figure:

import plotly.express as px

df = px.data.stocks()


def show(fig, *args, **kwargs):
    kwargs.get("config", {}).setdefault("displayModeBar", False)
    fig.show(*args, **kwargs)


df = px.data.stocks()
fig = px.line(df, x="date", y="GOOG")
show(fig)

The above sets the default value of config to {"displayModeBar": False}. The default value can simply be overwritten by passing arguments to the custom show function.

Post a Comment for "Plotly: Turn Off Modebar For The Session"