Is there a way to change the default config options (defined in plot_config.js) from the python API?

I want to change the default value for a particular config option. I’m using the python library, but the defaults are defined in plotly.js. Is there a way to edit them at runtime? Or some way to override them in python?

In case it’s relevant, I want to change the default value for toImageButtonOptions.scale. In my view, the default value (1) leads to low quality images.

Hi @grisaitis

You can modify the config settings in python as well - Configuration in Python

Thanks for your reply, @atharvakatre :slight_smile:

to clarify: my goal is to configure a global setting somewhere. i’m aware i can do fig.show(config=config), but i want to avoid having to do that every. time. i. call. fig.show. which is many times!

is there way to configure something globally? so that fig.show() has a different config option automagically?

1 Like

Hi! This would be a great and useful feature, any updates on this?

You could wrap the fig.show() or whatever function you might need to wrap.

import plotly.graph_objects as go

def wrapped(fig: go.Figure, config=your_custom_config):
    return fig.show(config=config)

your_custom_config = {'scrollZoom': True}

fig = go.Figure(
    go.Scatter(
        x=[1, 2, 3],
        y=[1, 3, 1]
    )
)

wrapped(fig)

Obviously this does not answer the initial question but might be a workaround.

1 Like

An even better solution is posted here: python - Plotly: Turn off modebar for the session - Stack Overflow. The problem is that it works for fig.show but it DOES NOT WORK for dcc.Graph.

I’ve created an issue at dash github: pio.renderers.config not reflected in dcc.Graph figure config Β· Issue #2687 Β· plotly/dash Β· GitHub.