Second y axis does not plot

I have the following dataframe, named ‘df’:

||Metered HVAC|Modeled HVAC|Metered CDD50|Metered HDD65|Modeled CDD50|Modeled HDD65|
| --- | --- | --- | --- | --- | --- | --- |

I’m trying to plot the first two columns as line traces with the first y axis, and the latter three columns as bars on a second y axis. This is my code:

traces = [
go.Scatter(x=df.index, y=df['Metered HVAC'].values, yaxis= 'y1'),
go.Scatter(x=df.index, y=df['Modeled HVAC'].values, yaxis= 'y1'),
go.Bar(x=df.index, y = df['Metered CDD50'].values, yaxis = 'y2'),
go.Bar(x=df.index, y = df['Metered HDD65'].values, yaxis = 'y2'),
go.Bar(x=df.index, y = df['Modeled CDD50'].values, yaxis = 'y2'),
go.Bar(x=df.index, y = df['Modeled HDD65'].values, yaxis = 'y2')
layout = go.Layout(legend={'orientation': 'h'},
                   yaxis1={'side': 'left'},
                   yaxis2={'side': 'right'})
fig = go.Figure(traces, layout)

When I plot it, both y axes show up , but only the ‘bars’ (yaxis2) traces are visible. I’ve looked online and tried switching up the yaxis formatting / labeling as well as using ‘plot’ instead of ‘iplot’, but no luck. Am I doing something wrong?


Hi @Msweeney,

I think you need to add overlaying='y' to the specification of yaxis2. See for example.

Hope that helps!