Show Sidebar Hide Sidebar

Colorway in Python

How to set default trace colors with colorway.

New to Plotly?

Plotly's Python library is free and open source! Get started by downloading the client and reading the primer.
You can set up Plotly to work in online or offline mode, or in jupyter notebooks.
We also have a quick-reference cheatsheet (new!) to help you get started!

Version Check

Plotly's python package is updated frequently. Run pip install plotly --upgrade to use the latest version.

In [1]:
import plotly

Set Default Trace Colors with colorway

In [2]:
import plotly.plotly as py
import plotly.graph_objs as go

import numpy as np

def parabola_gen(a, b):
    return lambda x: a * x ** 2 + b

parabolas = [parabola_gen(a, b) for a, b in zip(np.linspace(1, 3, 7), np.linspace(2, 14, 7))]
x = np.linspace(-1, 3)
data = [go.Scatter(x=x, y=p(x), mode='lines') for p in parabolas]

colorway = ['#f3cec9', '#e7a4b6', '#cd7eaf', '#a262a9', '#6f4d96', '#3d3b72', '#182844']
layout = go.Layout(colorway=colorway)

py.iplot(go.Figure(data=data, layout=layout))


See for more information about the colorway attribute