ryantkoehler
ryantkoehler

Reputation: 1

How to use named plotly qualitative color palette for traces in layout colorway with javascript

I am trying to use a named color palette for traces with a plotly scatter plot using javascript.

I have found how colors may be set with an explicit list of colors (below) but cannot figure out how to get such lists by name.

Here are named colors (at least in Python): https://plotly.com/python/discrete-color/#color-sequences-in-plotly-express

And this describes colorway use: https://plotly.com/javascript/reference/layout/#layout-colorway

// This works
var layout = {colorway: ['red', 'green', 'gold'],};
// (Does not work) Would like something like this
var layout = {colorway: 'Pastel',};
// (Does not work) Or something to get colors into a list (by name, not hardcode)?
var pastels = plotly.SomeFuncToGetColorList('Pastel');
var layout = {colorway: 'pastels,};

Note. Examples for Python use path-like syntax to get colors (e.g. plotly.colors.qualitative.Alphabet). I could not figure out a (working) similar path scheme for javascript code.

Upvotes: 0

Views: 289

Answers (0)

Related Questions