Subplots with two y axes, again

Thanks, empet, but I don’t have any problem with -secondary y-axes in simple single plots. My problem is that in multiple subplots, although I manage to get the right y-axis drawn using the update function as you suggested in Subplots with two y axes, the trace itself is not linked to that right y-axis. Here’s a simple example with the same problem:

from plotly import tools
import plotly
import plotly.graph_objs as go

trace1 = go.Scatter(x=[1, 2], y=[1.1, 2.1], name=‘1’)
trace2 = go.Scatter(x=[1, 2], y=[1.2, 2.2], name=‘2’,yaxis=‘y3’)
trace3 = go.Scatter(x=[1, 2], y=[1.3, 2.3], name=‘3’)
trace4 = go.Scatter(x=[1, 2], y=[1.4, 2.4], name=‘4’)
trace5 = go.Scatter(x=[1, 2], y=[1.5, 2.5], name=‘5’)
trace6 = go.Scatter(x=[1, 2], y=[1.6, 2.6], name=‘6’)

fig = tools.make_subplots(rows=2, cols=1, shared_xaxes=False, vertical_spacing = 0.5)

fig.append_trace(trace1, 1, 1)
fig.append_trace(trace2, 1, 1)
fig.append_trace(trace3, 2, 1)
fig.append_trace(trace4, 2, 1)
fig.append_trace(trace5, 2, 1)
fig.append_trace(trace6, 2, 1)

fig[‘layout’][‘xaxis1’].update(
domain=[0, 1],
range=[0, 3]
)
fig[‘layout’][‘yaxis1’].update(
title=‘yaxis 1 title’,
domain=[0.15, 1],
range=[-0.1, 3],
zeroline=True,
showline=True,
showgrid=True
)
fig[‘layout’][‘yaxis3’].update(
overlaying=‘y1’,
side=‘right’,
anchor=‘x1’,
domain=[0.15, 1],
range=[-0.1, 3],
zeroline=False,
showline=True,
showgrid=False,
title=‘yaxis 3 title’
)
fig[‘layout’][‘xaxis2’].update(
domain=[0, 1],
range=[0, 3]
)
fig[‘layout’][‘yaxis2’].update(
title=‘yaxis 2 title’,
domain=[0, 0.1],
range=[-0.1, 3]
)
fig[‘layout’].update(
title=‘Customizing Subplot Axes’,
showlegend=False
)

plotly.offline.plot(fig, filename=‘multiple-y-subplots2.html’)