Is there any kind of context manager for ad-hoc styling?

Hello everyone,

I’m still trying to get a decent working environment and since I have several types of output needed for my graphs, the obvious python tool would be a context manager. But I didn’t find any kind of implementation of that in the library documentation.

It would be basically something like this :

with plotly.set_template('custom_or_predefined'):
    fig = go.Scatter(etc..)
    pio.show(fig)

# or:
fig = go.Scatter(etc..)
with plotly.set_template('custom_or_predefined'):
     pio.show(fig)

I know I can fiddle each setting each time to get what I need but I really want to work fast when plotting. Any information or advices that can help me is very welcomed !

Best regards

There’s not context manager, no, but that’s a good idea! Right now you can set/unset the default template in plotly.io.templates.default but a context manager would make that pretty slick. We’d love a PR if you want to build it :slight_smile:

Hi @nicolaskruchten , I’m still very green since i come from a design background. But I will certainly work on it !

Thanks :slight_smile: