Colorway in JavaScript
How to use colorway to set default trace colors in JavaScript with Plotly.
Plotly is known for its graphing libraries, but it's also a broader ecosystem for building interactive data apps, AI data analysis tools, and deploying and hosting Dash apps. Explore the full set of tools and platforms designed to help turn data into action. Discover Plotly.
function linspace(a,b,n) {
return d3.range(n).map(function(i){return a+i*(b-a)/(n-1);});
}
const parabolaGen = (a, b) =>
x => x*x*a + b;
var as = linspace(1, 3, 7);
var bs = linspace(2, 14, 7);
var x = linspace(-1, 3, 50);
var data = [];
for (i=0; i< as.length; i++ ){
data.push({
type: "scatter",
mode: "lines",
x: x,
y: x.map(parabolaGen(as[i],bs[i]))
})
}
var layout = {
colorway : ['#f3cec9', '#e7a4b6', '#cd7eaf', '#a262a9', '#6f4d96', '#3d3b72', '#182844']
};
Plotly.newPlot('myDiv', data, layout);