我似乎无法在绘图中获得正确的垂直子图间距。目前,我的身材是这样的:
我想解决一些问题:
1)增加子图之间的间距,使图形变大
2) 增加每个 y 轴的大小,使刻度标签不重叠。
我在 plotly.tools.make_subplots
函数中没有看到任何控制图形大小的参数。如果有某种方法可以使图形更大,以便每个图都有更多空间,那就太好了。
最佳答案
一个最小的可重现示例
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_spacing
与layout['height']
结合使用来同时解决这两个问题。
fig = plotly.tools.make_subplots(rows=rows, cols=1, vertical_spacing=0.5/rows)
fig['layout'].update(height=1000)
关于python - 图中垂直子图的最大数量,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43145478/