Multiple Subplots with Multiple Y Axis

Hello,

I import the data from json file and I use python to plot the data in multiple subplots.
In every subplot, I have 3 different data, 2 on lines and 1 as a bar.
I would like the bar chart to be on the right Y-axis and the lines charts to be on the left Y-axis.

I use this line of code to present the on the right Y-Axis but i can pass the data from the corresponding Y and it isn’t communicating with the lines.

for k in range(1, 30):
fig[‘layout’].update({‘yaxis{}’.format(k+30):dict(range=[0, 500], anchor=‘x’+str(k), overlaying=‘y’+str(k), side=‘right’)})

All the code I have right is this:

import json
import plotly.graph_objs as go
from plotly.graph_objs import *
import plotly
import plotly.tools as plotly_tools
import numpy as np

import os
import tempfile

bm_basefile = '…json’
bm_currfile = ‘…json’

bm_basedata = json.load(open(bm_basefile))
layout = Layout(
paper_bgcolor=‘rgba(0,0,0,0)’,
plot_bgcolor=‘rgba(0,0,0,0)’
)

sp_index = 0
plot_titles = []
y_axis_title= []
x_axis_title= []
data = []

subplots = range(1,31)

y_ticker = 0
x_ticker = 0
for version in bm_basedata[‘data’]:
for bm_type in bm_basedata[“data”][version]:
for key in bm_basedata[“data”][version][bm_type]:

		plot_titles.append(version + "_" + bm_type + "_" + key)
		filename = bm_type + "-" + key
		bm_subtype = bm_basedata["data"][version][bm_type][key]
		bm_metric_chartdata = []


		for bm_metric in bm_subtype["y"]:
			tooltip_prefix = apiversion + "_" + bm_type + "_" + key + "_" + bm_metric + "_"

			if bm_metric  == 'tpm':
				chartdata_base = go.Bar(
					x=bm_subtype["x"],
					y=bm_subtype["y"][bm_metric],
					name=bm_metric + "_base",
					textposition='bottom'
				)
				chartdata_current = go.Bar(
					x=bm_subtype["x"],
					y=[((0.2 * float(n)) + float(n)) for n in bm_subtype["y"][bm_metric]],
					name=bm_metric + "_current",
					textposition='bottom'
				)
			else:
				chartdata_base = go.Scatter(
					x=bm_subtype["x"],
					y=bm_subtype["y"][bm_metric],
					name=bm_metric + "_base",
					textposition='bottom',
					mode = 'lines+markers'
				)

				chartdata_current = go.Scatter(
					x=bm_subtype["x"],
					y=[((0.2 * float(n)) + float(n)) for n in bm_subtype["y"][bm_metric]],
					mode='lines+markers',
					name=bm_metric + "_current",
					textposition='bottom',
				)



			bm_metric_chartdata.append(chartdata_base)
			bm_metric_chartdata.append(chartdata_current)
			print("sp_idx : " + str(sp_index))
			
			for ea in bm_metric_chartdata:
				ea.update( 
					  xaxis='x{}'.format(subplots[sp_index]),\
					  yaxis='y{}'.format(subplots[sp_index])
			)
		sp_index+=1
		data += bm_metric_chartdata

fig = plotly_tools.make_subplots(rows=10, cols=3, subplot_titles=plot_titles)

fig[‘layout’].update(showlegend=True, height=6000,width=1500, title=‘Benchmark Results’,
plot_bgcolor=‘rgba(228, 222, 249, 0.65)’)

for k in range(1, 30):
fig[‘layout’].update({‘yaxis{}’.format(k+30):dict(range=[0, 500], anchor=‘x’+str(k), overlaying=‘y’+str(k), side=‘right’)})

fig[‘data’] = Data(data)
plotly.offline.plot(fig, filename=‘benchmark_results.html’)

@nickchristoubeds, It isn’t sufficient to set the right yaxis in layout. You should insert in the corresponding
traces the following pairs, keys-values:

xaxis=‘x{}’.format(the corresponding k),
yaxis=‘y{}’.format(the corresponding j),

where k and j are integers chosen to set correctly the axes those traces are referenced to.