5

A plotly Figure has show() method which accepts a config argument, as per documentation

import plotly.graph_objects as go

fig = go.Figure()

config = dict({'scrollZoom': True})

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

fig.show(config=config)

This can be quite tedious, as I have to catch the Figure and show it with the show method instead of normal usage.

Instead of just doing

px.line(df)

Now I have to

fig = px.line(df)
fig.show(config=config)

In all charts. Is there a way through the Plotly library to define the config values globally, so that I can call px.line without setting the config per Figure instance, and I dont have to create a custom wrapper?

Nilo Araujo
  • 725
  • 6
  • 15
  • 1
    Does this answer your question? [Plotly: Turn off modebar for the session](https://stackoverflow.com/questions/67648403/plotly-turn-off-modebar-for-the-session) – aaron Jan 27 '23 at 12:59
  • The method there solves the problem but my question is generic and that question is more specific. Should that be a duplicate of this or it doesnt matter? – Nilo Araujo Jan 27 '23 at 17:22
  • How is this question generic? – aaron Jan 27 '23 at 17:26
  • That question asks how to change one setting of the config object. This question is about the config object itself. – Nilo Araujo Jan 27 '23 at 19:21
  • It's the same attribute on the renderers. – aaron Jan 27 '23 at 19:26

0 Answers0