Setting Y ticks on subplots shrinks plot

I am attempting to create a chart that we routinely create in Tableau plotting 19 thin horizontal stacked scatter plots we call “spark lines”.

plotly.__version__ = '4.8.1'

def sparklines(labels, bucket_df):
    fig = make_subplots(rows=len(labels), cols=1, shared_xaxes=True)
    for i in range(len(labels)):
        l = labels[i]
        max_y = bucket_df[l].max(skipna=True)
            go.Scatter(x=bucket_df["dt"], y=bucket_df[l], name=l),
            row=i+1, col=1
        y_tickvals=[0, max_y]
        y_ticktext=["", str(max_y)]
        #1) fig.update_yaxes(title_text="", showgrid=False, row=i+1, col=1)
        #2) fig.update_yaxes(title_text="", showgrid=False, tickvals=y_tickvals, ticktext=y_ticktext, row=i+1, col=1)

The chart plots full size when line #1) is uncommented. When line #2) is uncommented to clear up the messy text-on-text Y-axis the chart shrinks to 1/4 of its size and renders in the lower-right-hand corner of a large blank area. What about assigning the ticks causes the chart to shrink?

There are 19 labels that correspond with 19 columns in the DataFrame which also has ~1000 time buckets in the dt column. The dataset is very sparse with many Nans.

The problem was the empty string I used. If I use a single space instead of an empty string the problem does not occur. So there is a layout problem dealing with empty strings.

1 Like

Thank you for leaving the solution to your own question. This helped me resolve a similar, although not nearly an identical problem.