Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Cannot set colorscale in template for some trace types #3100

Copy link
Copy link
Closed
@jonmmease

Description

@jonmmease
Issue body actions

In working on developing templates for plotly.py I've found that I'm not able to set the colorscale and colorbar properties in the template for some trace types.

This works as I expect for the heatmap trace type. The defualt colorscale of Viridis and the colorbar tick properties are both applied.
Pen: https://codepen.io/jonmmease/pen/mzMeMW

var trace1 = {
  type: 'heatmap',
  z: [[1, 2, 3], [4, 5, 6]],
};

var data = [ trace1 ];

var layout = {
  template: {
    data: {
      heatmap: [{
        colorscale: 'Viridis',
        colorbar: {
          ticks: 'inside',
          ticklen: 10,
          tickcolor: 'white'
        }
      }],
    }
  }
};

Plotly.newPlot('myDiv', data, layout);

newplot-1

But it does not work for the scatter.marker colorscale and colorbar.
Pen: https://codepen.io/jonmmease/pen/LgjpQG

var trace1 = {
  type: 'scatter',
  y: [1, 2, 3],
  marker: {
    size: 20,
    color: [1, 2, 3],
    showscale: true
  },
  mode: 'markers'
};

var data = [ trace1 ];

var layout = {
  template: {
    data: {
      scatter: [{
        marker: {
          symbol: 'square',
          colorscale: 'Viridis',
          colorbar: {
            ticks: 'inside',
            ticklen: 10,
            tickcolor: 'white'
          } 
        }
      }],
    }
  }
};

Plotly.newPlot('myDiv', data, layout);

Note that scatter.marker.symbol is being picked up from the template, so I'm pretty sure the template specification is correct, but let me know if I'm missing something.

I've noticed this same behavior for other colorscales and colorbars, and I can work through an exhaustive list later today if that's helpful. Thanks!

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugsomething brokensomething broken

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      Morty Proxy This is a proxified and sanitized view of the page, visit original site.