Я думаю, что вы ищете это:
import plotly.offline as py
import plotly.graph_objs as go
import numpy as np
x0 = np.random.randn(500)
x1 = np.random.randn(500)+1
trace1 = go.Histogram(
x=x0,
opacity=0.75
)
trace2 = go.Histogram(
x=x1,
opacity=0.75
)
data = [trace1, trace2]
layout = go.Layout(barmode='overlay')
fig = go.Figure(data=data, layout=layout)
py.iplot(fig, filename='overlaid histogram')
Выход:
Или вы можете создать вспомогательные участки с общим xaxis:
from plotly import tools
import plotly.offline as py
import numpy as np
import plotly.graph_objs as go
trace1 = go.Histogram(
x=np.random.randn(500)
)
trace2 = go.Histogram(
x=np.random.randn(500)
)
fig = tools.make_subplots(rows=2, cols=1, specs=[[{}], [{}]],
shared_xaxes=True, shared_yaxes=False,
vertical_spacing=0.001)
fig.append_trace(trace1, 2, 1)
fig.append_trace(trace2, 1, 1)
fig['layout'].update(height=600, width=600, title='Stacked Subplots with Shared X-Axes')
py.iplot(fig, filename='stacked-subplots-shared-xaxes')
Выход: