Black Lives Matter. Please consider donating to Black Girls Code today.

Colorway in JavaScript

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

New to Plotly?

Plotly is a free and open-source graphing library for JavaScript. We recommend you read our Getting Started guide for the latest installation or upgrade instructions, then move on to our Plotly Fundamentals tutorials or dive straight in to some Basic Charts tutorials.

function linspace(a,b,n) {
  return Plotly.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++ ){
    type: "scatter",
    mode: "lines",
    x: x,

var layout = {
  colorway : ['#f3cec9', '#e7a4b6', '#cd7eaf', '#a262a9', '#6f4d96', '#3d3b72', '#182844']

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