1

Because, the height of all the subplots are same. I just want to increase the height of my first subplot only.

fig['layout'].update(height=700, width=1300, title='TITLE')

The above code gives me the total height and width. But I just want to increase the height of my first subplot plot and leave the other subplots unchanged when we are using Stacked subplots.

4

1 回答 1

0

您可以使用specs并设置第一个图的行跨度大于其他图

make_subplots 的 specs 参数用于配置每个子图的选项。specs 必须是一个二维列表,其维度与提供的 rows 和 cols 参数相匹配。

https://plotly.com/python/subplots/

例子:

from plotly.subplots import make_subplots
import plotly.graph_objects as go

fig = make_subplots(
    rows=4,
    cols=1,
    specs=[[{"rowspan": 2}], [{}], [{}], [{}]],
)

fig.append_trace(go.Scatter(x=[0, 1, 2], y=[10, 11, 12]), row=1, col=1)
fig.append_trace(go.Scatter(x=[0, 1, 2], y=[10, 11, 12]), row=3, col=1)
fig.append_trace(go.Scatter(x=[0, 1, 2], y=[10, 11, 12]), row=4, col=1)
fig.update_layout(height=600, width=600)

fig.show()

结果:

结果

于 2021-07-23T09:37:50.647 回答