删除 Plotly 中子图之间的 space?

Remove space between subplots in Plotly?

我在 plotly 的子图之间有一个很大的 space。在 matplotlib 中,有一种称为紧密布局的布局可以消除这种情况。 plotly中有没有类似的布局?我正在 iPython 笔记本中绘图,因此 space 有限。请参见下图中的 space。

是的!您可以使用 specsvertical_spacinghorizontal_spacing。这是 horizontal_spacing 的示例:

from plotly import tools
import plotly.plotly as py
from plotly.graph_objs import *

trace1 = Scatter(
     x=[1, 2, 3],
     y=[4, 5, 6]
)
trace2 = Scatter(
     x=[20, 30, 40],
     y=[50, 60, 70],
)

fig = tools.make_subplots(rows = 1, cols = 2, specs = [[{}, {}]],
                          horizontal_spacing = 0.05)

fig.append_trace(trace1, 1, 1)
fig.append_trace(trace2, 1, 2)

py.iplot(fig, filename='make-subplot-horizontal_spacing')

您可以在 Plotly 子图页面找到更多教程:Plotly subplots tutorial