小编Har*_*ari的帖子

Python Plotly 图表 - 为每个facet_row生成不同的y轴

我正在尝试使用plotly(v 5.11.0)绘制图表,其中我试图为每个facet_row生成不同的y轴。y 轴应与该facet_row 内的所有facet_col 匹配。

使用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= "")
Run Code Online (Sandbox Code Playgroud)

python-3.8 plotly-express

5
推荐指数
1
解决办法
645
查看次数

标签 统计

plotly-express ×1

python-3.8 ×1