Search code examples
pythonplotlyplotly-python

Change line color in Plotly


How do 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 I suspect that doesn't work because this is a simple line.


Solution

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