Skip to content

Problems opting out of the default template #1870

Closed
@nicolaskruchten

Description

@nicolaskruchten

Original observation: neither call here suppresses the default template:

from plotly.offline import iplot
iplot(dict(data=[dict(type="scatter")], layout=dict(template="none")))
iplot(dict(data=[dict(type="scatter")], layout=dict(template={})))

Popping the hood on that method, it looks like it's doing the equivalent of:

import plotly.graph_objects as go
fig = go.Figure(dict(data=[dict(type="scatter")], layout=dict(template={})))

import plotly.io as pio
pio.show(fig.to_dict())

The problem being that fig.to_dict() here returns {'data': [{'type': 'scatter'}], 'layout': {}} and when pio.show() gets it, it seems to applies the default template. This doesn't happen with pio.show(fig.to_dict(), validate=False) or with pio.show(fig.update_layout(template={}, overwrite=True).to_dict(), validate=False).

So should pio.show() be applying the default template at all here? (Hard to say "no" here unless we do validation somehow without just creating a Figure ?)

And/or should fig.to_dict() include the template: {} to signal to functions like pio.show() that no defaulting should happen?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions