是否可以对某些特定的子图使用 share_xaxis ?

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

我使用 make_subplot 绘制 3 行 1 列,前 2 行是数据图,最后一行是图像。我想对前两个数据图使用shared_xaxis,如何通过排除图像图的最后一行来做到这一点?谢谢

fig = make_subplots(rows=3, cols=1, 
                vertical_spacing=0.05, 
                specs=[[{"secondary_y": False}],[{"secondary_y": True}],[{"secondary_y": False,"type": "image"}]],  #
                subplot_titles=(plot_title_1stsubplot,plot_title_2ndsubplot
                               ),
                row_heights=[0.7,0.15,0.15],
                shared_xaxes=False,
               )
python plotly
1个回答
0
投票

请注意,设置

shared_xaxes
(
shared_yaxes
) 是设置 x (y) 轴之间的
matches
约束的快捷方式:

matches
- 如果设置为另一个轴 id(例如
x2
y
),则该轴的范围 将匹配数据坐标中相应轴的范围 空间。此外,匹配轴共享自动范围值、类别列表 和直方图自动分类。

您可以使第二个子图(第 2 行)的 x 轴与第一个子图(第 1 行)的 x 轴匹配:

fig.update_xaxes(row=2, matches='x')

或者相反:

fig.update_xaxes(row=1, matches='x2')
© www.soinside.com 2019 - 2024. All rights reserved.