背景
具有相同高度 (✘) 的不同子图 (✔)
我可以创建一个带有共享 X 轴的子图(示例改编自Plot.ly doc),子图之间有适当的分隔,并且您可以通过subplot_titles以下方式为每个子图插入特定标题:
from plotly import tools
import plotly.plotly as py
import plotly.graph_objs as go
trace1 = go.Scatter(
x=[0, 1, 2],
y=[10, 11, 12]
)
trace2 = go.Scatter(
x=[2, 3, 4],
y=[100, 110, 120],
)
trace3 = go.Scatter(
x=[3, 4, 5],
y=[1000, 1100, 1200],
)
fig = tools.make_subplots(rows=3, cols=1, specs=[[{}], [{}], [{}]],
shared_xaxes=True, shared_yaxes=True,
vertical_spacing=0.1, subplot_titles=('subtitle 1',
'subtitle 2', 'subtitle 3'))
fig.append_trace(trace1, 3, 1)
fig.append_trace(trace2, 2, 1)
fig.append_trace(trace3, 1, 1)
fig['layout'].update(height=600, width=600, title='Subplots with Shared X-Axes')
py.plot(fig, filename='subplots-shared-xaxes')
慕丝7291255
相关分类