我正在尝试在同一 x 轴和 y 轴上绘制多个条形图。我不想要堆叠或分组的条形图。我只想让多个条形图与长 x 轴并排,其中 x 轴刻度根据条形图的数量重复,y 轴沿条形图共享并放置在图表的最左侧.
这是我的代码,但它不会产生我想要的输出
import plotly.offline as pyo
import plotly.graph_objs as go
from plotly import tools
trace1 = go.Bar(
x=[1, 2, 3],
y=[10, 11, 12]
)
trace2 = go.Bar(
x=[1, 2, 3],
y=[100, 110, 120],
)
trace3 = go.Bar(
x=[1, 2, 3],
y=[1000, 1100, 1200],
)
fig = tools.make_subplots(rows=3, cols=1, specs=[[{}], [{}], [{}]],
shared_xaxes=True, shared_yaxes=True,
vertical_spacing=0.001)
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='')
pyo.plot(fig, filename='bar-charts-with-shared-axis.html')
任何帮助,将不胜感激