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)
fig.add_trace(
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)
fig.show()
#
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.