Plotly Express subplots: space between subplots for labels

Hi,

I am currently using the following plotly express syntax to generate two subplots:

fig = px.line(
        df,
        x="snapshot_day",
        y="value",
        facet_col="cost_or_units",
        color="variable",
    )
fig.update_yaxes(showticklabels=True, nticks=20)

The output looks as follows:

I would like to provide some spacing between the left plot and the yaxis labels of the right plot. Would be nice if there was some dynamic way to space it as I have some charts that can have 3(-4) digits.

Thanks in advance!!

Hi @hiqbal2

Try adding to your figure:
px.line(facet_col_spacing=0.1)

Your options are float between 0 and 1. The default is 0.02.

You can do the same thing with rows. See more here.

2 Likes