plotly.js

The open source JavaScript graphing library that powers Plotly

Show Sidebar Hide Sidebar
Plotly.js

Colorway in plotly.js

How to use colorway to set default trace colors in Javascript with Plotly.

var linspace = require('linspace');
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);

plotly.js runs on all SVG-compatible browsers

Still need help?
Contact Us

For guaranteed 24 hour response turnarounds, upgrade to a Developer Support Plan.