Dear Experts,
i am unable to plot the secondary Y axis in this code… Kindly share if there is any link to study and get this code corrected or if you guys can help!!!
prepare data frame
from plotly.offline import iplot
from plotly.subplots import make_subplots
df2 = df.iloc[:100,:]
import graph objects as “go”
import plotly.graph_objs as go
Create figure with secondary y-axis
fig = make_subplots(specs=[[{“secondary_y”: True}]])
Creating trace1
trace1 = go.Scatter(
x = df2.DEP,
y = df2.IND,
mode = “lines”,
name = “DELTA”,
marker = dict(color = ‘rgba(16, 112, 2, 0.8)’),
text= df2.IND)
Creating trace2
trace2 = go.Scatter(
x = df2.DEP,
y = df2.SU,
mode =“lines+markers”,
name = “SOUTHWEST”,
marker = dict(color = ‘rgba(80, 26, 80, 0.8)’),
text= df2.SU)
Creating trace3
trace3 = go.Bar(
x = df2.DEP,
y = df2.PAX,
name = “Pax”,
text= df2.PAX)
fig.add_trace(trace1, secondary_y=False);
fig.add_trace(trace2, secondary_y=False);
fig.add_trace(trace3, secondary_y=True);
data = [trace1, trace2,trace3]
layout = dict(title = ‘DELTA vs SU Fare comparison’,
xaxis= dict(ticklen= 5,zeroline= False,
title= ‘Departure Dates’,secondary_y=False);
yaxis= dict(range=[0,1000],
title= ‘Pax’,secondary_y=False);
yaxis= dict(range=[0,20],
title= ‘fares’,secondary_y=True);
fig = dict(data = data, layout = layout)
iplot(fig)