4

I'm using plotly dash to create a line chart and want to change the lines to a specific color. You'll see this in my code, but it doesn't change the colors from the default. I'm guessing I'm doing this wrong. There is a way to change the color right? And if so, how do I fix this?

dcc.Graph(id='henry',
        figure={
            'data':[
                {'x':dates,'y':henrycases,'type':'line','name':'Cases','color':'red'},
                {'x':dates,'y':henrydf,'type':'line','name':'Wait Time','color':'black'}
                ],
            'layout':{
                'title':'Henry County Wait Time and New Cases per Day'
                }

1 Answer 1

3

You can specify the line colors like this

dcc.Graph(
    id='henry',
    figure={
        'data': [
            {'x':dates,'y':henrycases,'type':'line','name':'Cases','line':dict(color='red')},
            {'x':dates,'y':henrydf,'type':'line','name':'Wait Time','line':dict(color='black')}
        ],
        'layout': {
            'title':'Henry County Wait Time and New Cases per Day'
        }
    }
)

Alternatively like this

dcc.Graph(
    id='henry',
    figure={
        'data': [
            {'x':dates,'y':henrycases,'type':'line','name':'Cases','line_color':'red'},
            {'x':dates,'y':henrydf,'type':'line','name':'Wait Time','line_color':'black'}
        ],
        'layout': {
            'title':'Henry County Wait Time and New Cases per Day'
        }
    }
)
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.