我试图使用plotly (v 5.11.0)绘制图表,我试图为每个facet_row生成不同的y轴。y轴应该匹配该facet_row中的所有facet_cols。
使用fig.update_yaxes(matches = None)
似乎不能解决上述问题。如果可能,请提出解决方案。
fig = px.bar(query_fb, x = "modelName",
y = "value", facet_col = "holdingPeriod",
facet_col_wrap = 3,
facet_row = 'dataItem',
color = "modelName")
fig.for_each_yaxis(lambda y: y.update(title = ''))
fig.for_each_annotation(lambda a: a.update(
text=a.text.split("=")[-1]))
yxs = dict(tickformat = yaxisfmt )
fig.update_xaxes(visible=False)
fig.update_yaxes(yxs, tickformat = yaxisfmt,hoverformat = yaxisfmt)
fig.update_layout(autosize=False,
width= 250*len(self.modelId),
height=600,
margin=dict(l=50, r=10, b=60, t=60),
#legend= dict(orientation="h",),
title_x = 0.2,title= "")
没关系,我找到了适合我的答案。感谢所有!
for row_idx, row_figs in enumerate(fig._grid_ref):
for col_idx, col_fig in enumerate(row_figs):
fig.update_yaxes(row=row_idx+1, col=col_idx+1,
matches = 'y'+str(len(row_figs)*row_idx+1))