如何在多行主标题中添加情节副标题?

问题描述 投票:0回答:1

考虑以下Python代码:

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

fig = make_subplots(
    rows=2, cols=1,
    subplot_titles=("Plot 1", "Plot 2"))

fig.add_trace(go.Scatter(x=[1, 2, 3], y=[4, 5, 6]),
              row=1, col=1)
fig.add_trace(go.Scatter(x=[300, 400, 500], y=[600, 700, 800]),
              row=2, col=1)
title_text = "Multiple Subplots with Titles<br>Multiple Subplots with Titles<br>Multiple Subplots with Titles<br>Multiple Subplots with Titles<br>Multiple Subplots with Titles"

fig.update_layout(title_text=title_text, title_x=0.5)
fig.show()

生成:

如何将所有子图下推,为多行主标题以及第一个子图的副标题腾出空间?

python plotly
1个回答
0
投票

只需添加选项

title_automargin=True

fig.update_layout(title_text=title_text, title_x=0.5, title_automargin=True)

© www.soinside.com 2019 - 2024. All rights reserved.