How do I add an axis for a second trace in a Plotly subplot?
<p>I have three traces, one of which I have in one subplot, and two of which are in another. I would like to have a distinct y-axis each of the traces in the subplot with 2 traces.</p>

<p>For example, I have</p>

<pre><code>fig = plotly.tools.make_subplots(rows=2, cols=1, shared_xaxes=True)
fig.append_trace(trace1, 1, 1)
fig.append_trace(trace2, 1, 1)
fig.append_trace(trace3, 2, 1)
fig['layout'].update(height=200, width=400)
</code></pre>

<p>which produces</p>

<p><a href="https://i.stack.imgur.com/7aA5p.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/7aA5p.png" alt="enter image description here"></a></p>

<p>And when I have no subplots, I can get a second axis for the second trace with</p>

<pre><code>layout = go.Layout(
    yaxis=dict(
        title='y for trace1'
    ),
    yaxis2=dict(
        title='y for trace2',
        titlefont=dict(
            color='rgb(148, 103, 189)'
        ),
        tickfont=dict(
            color='rgb(148, 103, 189)'
        ),
        overlaying='y',
        side='right'
    )
)
fig = go.Figure(data=data, layout=layout)
</code></pre>

<p>which produces</p>

<p><a href="https://i.stack.imgur.com/sKvbj.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/sKvbj.png" alt="enter image description here"></a></p>

<p>But I can't figure out how to get the first subplot in the first example to look like the plot in the second example: with a distinct axis for the second trace there.</p>

<p>How do I add an axis for a second trace in a Plotly subplot?</p>