Hi All,
Iβm trying to make the first 2 rows of my plot always stay the same height (example here: 200 px and 180 px). However, depending on the number of lines plotting on the 3rd row the total height of the figure should increase. When I do this, the heights of the first two rows change and I wanna avoid that. Iβd appreciate if anybody can help.
minimal reproducible code:
def plot_test(n):
heights = [200,180,n * 15]
plot_height = sum(heights)
row_heights = [x / plot_height for x in heights]
fig = make_subplots(rows=3, cols=1,
shared_xaxes=True,
vertical_spacing=50/plot_height,subplot_titles=["test 1", "test 2", "test 3"] , row_heights=row_heights)
fig.add_trace(go.Scatter(x=[0, 1, 2], y=[10, 11, 12]),
row=1, col=1)
fig.add_trace(go.Scatter(x=[2, 3, 4], y=[100, 110, 120]),
row=2, col=1)
for i in range(n):
fig.add_trace(go.Scatter(x=[3, 4, 5], y=[i, i, i],connectgaps=True,
marker={
"color": "grey",
"size": 6,
"symbol": "square",
},
name="",
showlegend=False,),
row=3, col=1)
fig.update_layout(height=plot_height, width=600,
title_text="Stacked Subplots with Shared X-Axes")
fig.show()
first example:
plot_test(5)
second example:
plot_test(25)
Iβd also want the spacing between each line on the last row stays the same no matter what n is