Reputation: 1997
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.line(df, x='date', y='GOOG')
fig.show(config={'displayModeBar':False})
But is there a way I could do it just once for the entire session rather than having to pass it with each figure call?
Upvotes: 4
Views: 854
Reputation: 1042
import plotly.io as pio
pio.renderers['jupyterlab'].config['displayModeBar'] = False
Upvotes: 3
Reputation: 15722
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.
Upvotes: 0