调整 rangeslider 高度以防止它与子图重叠?

tweaking rangeslider height in plotly to prevent it from overlapping with subplots?

范围滑块太粗,与下一个子图重叠。我可以增加子图之间的垂直间距或整个图的高度(如此处建议:https://community.plotly.com/t/rangeslider-overlaps-with-subplots/35169)但这会使图不成比例,并且随着子图数量的增加而变得更糟。范围滑块太厚了。

我可以只更改范围滑块的高度吗?

这是一个 MWE:

import numpy as np 
import pandas as pd

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

n_plots = 2

data = pd.DataFrame()
for i in range(n_plots):
    data[i] = np.random.randn(100)
data

fig = make_subplots(
    rows = n_plots,
    cols = 1,
    vertical_spacing = 0.1,
    shared_xaxes = True
)

for i in range(n_plots):
    fig.add_trace(
        go.Scatter(
            y = data[i]
        ),
        row = 1+i, col = 1
    )

fig.update_layout(
    height = 800,
    width = 800,
    xaxis_rangeslider_visible = True,
)

是的,您可以使用以下方法更改范围滑块高度(厚度):

fig.update_layout(
    xaxis_rangeslider_visible = True,
    xaxis_rangeslider_thickness = 0.04
)

对于与第 n 个 x 轴关联的范围滑块,您将使用:xaxisn_rangeslider_thickness