Plotly: How to set line color?

Vader picture Vader · Oct 1, 2019 · Viewed 16.6k times · Source

How can I set the color of a line in plotly?

import plotly.graph_objects as go
from plotly.subplots import make_subplots


fig = make_subplots(rows=2, cols=1, subplot_titles=('Plot 1', 'Plot 2'))

# plot the first line of the first plot
fig.append_trace(go.Scatter(x=self.x_axis_pd, y=self.y_1, mode='lines+markers', name='line#1'), row=1, col=1)  # this line should be #ffe476

I tried fillcolor but that I suspected doesn't work because this is a simple line.

Answer

nicolaskruchten picture nicolaskruchten · Oct 1, 2019

You can add line=dict(color="#ffe476") inside your go.Scatter(...) call. Documentation here: https://plot.ly/python/reference/#scatter-line-color