Order of marginal wrong when using facet_col and setting traces to invisible by default
未关闭
还没有人认领这个 Issue。
bug
P3
- 主要语言
- Python
- 星标
- 18.8k
- 派生
- 2.8k
- 平均合并
- 16 小时 26 分钟
- 30 天内合并 PR
- 21
描述
I am creating a histogram plot using plotly express.histogram, like the following:
df = pd.DataFrame({
'month': [5] * 30 + [6] * 30 + [7] * 30,
'value': np.random.randint(0, 100, size=90),
'Module': ['M', 'P']*45,
})
fig = px.histogram(
df,
x='value',
opacity=0.8,
color='month',
category_orders={'month': df['month'].sort_values(ascending=True)},
marginal='box',
barmode='overlay',
facet_col='Module',
)
for trace in fig.data:
if int(trace.name) not in (7,6):
trace.visible = "legendonly"
fig.show()
When I then want to show month 5 as well, the box in marginal is placed at the top of the others, giving the wrong order of month: 5, 7, 6 (red from top to bottom).
The problem does not appear when I don't use the facet_col argument, or when i show all month from the beginning (simply comment the part where i set trace.visible to legendonly).
plotly version: 5.18.0
贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
调研方向
首先使用 plotly 5.18.0 运行提供的 plotly.express.histogram 示例,比较将 traces 设置为 legendonly 与显示所有 traces 时 facet_col 和 marginal 的行为。跟踪 marginal box 的顺序是如何生成的,并验证显示月份 5 后类别顺序 5, 6, 7 仍然保持不变。
由索引模型根据 Issue 内容生成。
评估
- 技术栈
- python
- 领域
- data-visualization
- Issue 类型
- 缺陷
- 难度
- 4/5
- 预计耗时
- 3-5 天
- 活跃度
- 停滞
- 描述清晰度
- 基本清楚
- 新手友好度
- 35/100