Skip to content

Templates overwrite colorscale property of traces. #1454

Closed
@SaschaJust

Description

@SaschaJust

Hi,

first of all, thank you for introducing template support to plotly.

As far as I understand, template settings should only "replace" default values but never overwrite explicit properties of a plot. However, when using colorscale in heatmaps, the colorscale is always overwritten by the template, no matter if it's specified by alias or as a list.

Consider the following example:

import plotly.graph_objs as go
import plotly.offline as py
from plotly import __version__ as V
py.init_notebook_mode(connected=True)

print(V)

trace = go.Heatmap(
    x = list(range(1,10)),
    y = list(range(1,10)),
    z = list(range(1,10)),
    colorscale = [[0, 'rgb(255,0,0)'], [1, 'rgb(0,255,0)']]
)

layout = go.Layout(
    title = 'Colorscale templating test',
    template = 'ggplot2'
)

fig = go.Figure([trace], layout)

py.iplot(fig)

Result

In this case, the ggplot2 theme's colorscale will be used rather the one explicitly specified in the trace.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugsomething broken

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions