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

Dash subplot and 3rd y-axis

Hi all, I’m a new Dash/Plotly user and I think it’s amazing.

I’ve created a subplot with dimenison (2,1), screenshot attached.

sample

I’ve added the charts using:

    fig.append_trace(trace1, 1, 1)
    fig.append_trace(trace2, 1, 1)
    fig.append_trace(trace3, 2, 1)

trace2 in particular is done via

    trace2 = go.Scatter(
        x=x_data,
        y=y_data,
        yaxis='y2'
    )

The outcome is almost exactly what I want, however I need trace2 to appear on the y-axis on the right handside, mirroring x.

I tried below code but confusingly that made both trace1 and trace 2 to disappear from the chart, only leaving trace3.

    fig['layout'].update(
            yaxis2=dict(
                        overlaying='y',
                        anchor='free',
                        side='right'
                        ))

What am i doing wrong?

Thanks very much

Felton

Hello @Felton, I think this example https://plot.ly/python/multiple-axes/#muliple-yaxes-subplots shows how to do what you want: subplots with secondary y axis. Hopes this helps! Emma

1 Like

Thanks! Read through the examples and it’s very clear.