Problem with switching to secondary y axis with one of my subplots

Hi, I’m having a small problem which is giving me a big headache.

I’m trying to set my horizontal bar graph which is located in the bottom right of my subplot area to the secondary y axis, and read from right to left. I’ve got it working, except when I set the add_trace parameter secondary_y=True, that subplot all of a sudden decides to span to the upper row (which it doesn’t otherwise.

Here it is without add_trace(secondary_y=True):
Almost working

Here is is with add_trace(secondary_y=True):
Not working

Here is the code:

# Create the subplots 
fig = make_subplots(rows=2, 
                    cols=2,
                    row_heights=[0.3, 0.7],
                    specs=[[{"type": "xy", "colspan": 2}, None],
                           [{"type": "xy"}, {"type": "xy", "secondary_y": True}]],
                    subplot_titles=['Distribution of Ratings', 
                                    "Logistic Regression <br> Most Important Features", 
                                    "XG Boost <br> Most Important Features"], 
                    horizontal_spacing=0.05)

LR_CD = go.Bar(y=lr_t10['Coef'], 
               x=lr_t10['Value'], 
               name="Coefficient", 
               hovertemplate='%{x}', 
               orientation='h')
XG_CD = go.Bar(y=xg_t10['Coef'], 
               x=xg_t10['Value'], 
               name='Gain', 
               hovertemplate='%{x}', 
               orientation='h')
imdb_CD = go.Histogram(x=y['Per_Profit'], 
                       name='Count', 
                       hovertemplate="%{y}")

# Add the graph objects
fig.add_trace(imdb_CD, row=1, col=1)
fig.add_trace(LR_CD, row=2, col=1)
fig.add_trace(XG_CD, row=2, col=2, secondary_y=True)

fig['layout']['xaxis1'].update(title='Rating')
fig['layout']['xaxis3'].update(autorange='reversed')

fig['layout']['yaxis1'].update(title='Count')
fig['layout']['yaxis2'].update(title='Coefficient')
fig['layout']['yaxis3'].update(title='Gain')


# Update the layout and show
fig.update_layout(height=800, 
                  width=1000,
                  title_text="Profit Margin Results")
fig.show()



# Loading onto cloud
py.iplot(fig, filename="Profit_not_working")

Any help would be much appreciated!

Was going to delete, but I’ll leave it up with the solution I found for future people.

In the plotly editor (once you publish the graph you can access it though the editor) you can select an option in the subplot menu called Y anchor under the correct subplot you are looking to change. Switch that from left to right and it will switch the labels and titles without blowing up.

I realize that if you can do this in the editor you can do it in code but I can’t be fucked.