Cannot set colorscale in template for some trace types
See original GitHub issueIn 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);
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!
Issue Analytics
- State:
- Created 5 years ago
- Comments:6 (6 by maintainers)
Top GitHub Comments
One more issue here. Setting
marker.autocolorscale: false
in the template causes the colorscale to be displayed properly if the template is already in place when the scatter trace is created. But if the template is applied withrelayout
after the scatter trace is added, the template’s colorscale is not applied.No unfortunately. Only
newPlot
will behave correctly onlayout.template
edits.