Black Lives Matter. Please consider donating to Black Girls Code today.

Two y axis in one chart

Hi Team,

I’m having a hard creating two y axis in my chart here is my sample code below:

traces = []
traces.append(go.Bar(
x=df_invoice_creds[‘Date’],
y=df_invoice_creds[‘INVOICES’],
name=‘Invoices’
))

traces_creds = []
traces_creds.append(go.Scatter(
        x=df_invoice_creds['Date'],
        y=df_invoice_creds['CREDITS'],
        name='Credits',
        yaxis='y2'
))
return html.Div([
    dcc.Graph(
            id='invoices_creds',
            figure={
                'data': traces,
                'layout': {
                    'margin': {'l': 80,'r': 0,'b': 50,'t': 30   },
                    'yaxis': dict(title='Invoices(vol)'),
                    'yaxis2': dict(
                                title='Credits',
                                titlefont=dict(
                                color='rgb(148, 103, 189)'
                            ),
                                tickfont=dict(
                                color='rgb(148, 103, 189)'
                            ),
                                overlaying='y',
                                side='right',
                                tickvals=[2,6,8,9]
                    ),
                    'height': 300,
                'legend': {'x': 'dash', 'y': 'test'},
                'title':'Invoices for ' + str(iot) + ' ' + str(selected_brand)
                }
            },
            #animate=True,
        )
]),

Appreciate your help and thank you in advance.

Warm Regards,
Paul Caballero