-1

I am using Dash to create a web app, and showing some plotly charts.

My callback has the following code:

for fig in [fig1, fig2, fig3]:
    fig.update_layout(
        margin=dict(r=20, l=20, b=20, t=50),
        spikedistance=-1,
        hovermode='x unified',
        plot_bgcolor='rgb(255,255,255)',
        legend=dict(yanchor='top', y=0.95, xanchor='left', x=0.05, bordercolor='lightgray', borderwidth=1),
    )
    fig.update_traces(hovertemplate=None)
    fig.update_xaxes(title=None,
                     spikemode='across', spikedash='solid', spikecolor='black', spikethickness=1)

    fig.update_yaxes(gridcolor='lightgray', showline=True, title=None,
                     zeroline=True, zerolinecolor='lightgray')

return fig1, fig2, fig3

I don't like the plotly default colors, and am trying to change them.

I tried adding the following to fig.update_layout:

colorway = ['black','red','blue']

But it doesn't work to change the colours of the lines.

What am I doing wrong?

Thev
  • 1,105
  • 2
  • 13
  • 24

1 Answers1

0

The colors of plotly are set in this file and can be retrieved with the simple command of plotly.colors.DEFAULT_PLOTLY_COLORS. Pure speculation: try setting this plotly.color.DEFAULT_PLOTLY_COLORS to a different list of HEX colors.

Robin van Hoorn
  • 334
  • 1
  • 10
  • Unfortunately, that doesn't seem to work. – Thev Jan 06 '21 at 09:21
  • made a spelling mistake in my original answer so if you copied one or the other, it might have gone wrong? Maybe try both with `color` and `colors`? Feel like the correct one is the second tho if i remember correctly. – Robin van Hoorn Jan 06 '21 at 15:05