The Below code works fine to have 3 subplot with make_subplots(2 row, 2 col)
with specs=[[{}, {}],[{"colspan": 2}, None]]
. now I want to have secondary Y axis on first two plot using spec
. but it throwing error the 'specs' argument to make_subplots must be a 2d list of dictionaries with dimensions (2 x 2)
I tried something fig = make_subplots(rows=2, cols=2, specs=[[{}, {}], [{"colspan": 2}, None]][[{"secondary_y": True}, {"secondary_y": True}], [{"secondary_y": True}, {"secondary_y": True}]]), subplot_titles=("Change in OI/ LTP CALL","Change in OI/ LTP PUT", "COI/Volume"))
import dash
import dash_core_components as dcc
import dash_html_components as html
from dash.dependencies import Input, Output
import pandas as pd
import plotly.graph_objs as go
import datetime
import plotly.tools as tls
import plotly.express as px
from plotly.subplots import make_subplots
#print list(df2.Portal)
app = dash.Dash(__name__)
app.layout = html.Div(
html.Div([
html.H4('Interval Test'),
dcc.Graph(id='live-update-graph', animate = False),
dcc.Interval(
id='interval-component',
interval=1*10000, # in milliseconds
n_intervals=0
)
])
)
@app.callback(Output('live-update-graph', 'figure'),
[Input('interval-component', 'n_intervals')])
def update_graph_live(n):
fig = make_subplots(rows=2, cols=2, specs=[[{}, {}],
[{"colspan": 2}, None]], subplot_titles=("Change in OI/ LTP CALL","Change in OI/ LTP PUT", "COI/Volume"))
fig.add_scatter(x=s.index, y=s[('Chng in OI_ce')], mode="lines", row=1, col=1,name="Change in Call OI")
fig.add_scatter(x=s.index, y=s[('LTP_ce')], mode="lines", row=1, col=1, name="LTP Call")
fig.add_scatter(x=s.index, y=s[('Chng in OI_pe')], mode="lines", row=1, col=2, name="Change in Put OI")
fig.add_scatter(x=s.index, y=s[('LTP_pe')], mode="lines", row=1, col=2,name="LTP Put")
fig.add_scatter(x=s.index, y=s[('CoI_Vol_ce')], mode="lines", row=2, col=1,name="CoI/Volume")
fig.add_scatter(x=s.index, y=s[('CoI_Vol_pe')], mode="lines", row=2, col=1,name="PoI/Volume")
fig.update_layout(height=700, showlegend=True,template='plotly_dark')
return fig
if __name__ == '__main__':
app.run_server(debug=True)