The first row’s box plots are confined to the left half of the subplot, and the second row’s box plots are confined to the right half of their subplot, so that neither row’s box plots are properly filling up their respective space. How do I properly space them (in Jupyter Notebook)?
from plotly import subplots
import plotly.graph_objects as go
fig = subplots.make_subplots(rows=2,
cols=1,
shared_xaxes=True,
subplot_titles=['Credit Score', 'Annual Mileage'],
vertical_spacing=0.05)
fig.update_xaxes(showticklabels=False)
fig.update_layout(width=900, height=800)
fig.add_trace(go.Box(y=train_copy_pre_impute['CREDIT_SCORE'], name="Credit Score (Pre-Imputation)"), row=1, col=1)
fig.add_trace(go.Box(y=X_train['CREDIT_SCORE'], name="Credit Score (Post-Imputation)"), row=1, col=1)
fig.add_trace(go.Box(y=train_copy_pre_impute['ANNUAL_MILEAGE'], name="Mileage (Pre-Imputation)"), row=2, col=1)
fig.add_trace(go.Box(y=X_train['ANNUAL_MILEAGE'], name="Mileage (Post-Imputation)"), row=2, col=1)
If you use
shared_ xaxes
, they are treated independently, so changingshared_xaxes=False
will produce the intended result.@r-beginners Thanks!