图中垂直子图的最大数量

Maximum number of vertical subplots in plotly figure

我似乎无法在 plotly 中正确设置垂直子图的间距。目前,我的身材是这样的:

有几件事我想解决:

1) 增加subplots之间space的数量,只是让图变大

2) 增加每个 y 轴的大小,使刻度标签不重叠。

我在 plotly.tools.make_subplots 函数中没有看到任何控制图形大小的参数。如果有什么方法可以把图变大,让每块图都多space,那就太好了。

一个最小的可复制示例

import plotly
plotly.offline.init_notebook_mode()
import random
rows = 10
traces = [[random.random() for j in range(100)] for i in range(rows)]

fig = plotly.tools.make_subplots(rows=rows, cols=1)
for i in range(1, rows + 1):
    p = plotly.graph_objs.Bar(y=traces[i - 1], showlegend=False)
    fig.append_trace(p, i, 1)
plotly.offline.iplot(fig)

生产

1) Increase the amount of space between subplots, and just make the figure larger

2) Increase the size of each y-axis so that the tick labels aren't overlapping.

您可以结合使用 vertical_spacinglayout['height'] 来同时解决这两个问题。

fig = plotly.tools.make_subplots(rows=rows, cols=1, vertical_spacing=0.5/rows)
fig['layout'].update(height=1000)