plotly / plotly/plotly.py

Order of marginal wrong when using facet_col and setting traces to invisible by default

オープン
#4,438 コメント 1 件 リアクション 0 件 担当者 0 名 GitHub で見る

まだ誰も着手していません。

bug P3
主要言語
Python
スター
18.8k
フォーク
2.8k
平均マージ
16時間 26分
マージ済み PR(30日)
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

Screenshot 2023-11-22 153608

コントリビューションガイド

コントリビューションガイドを開く

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

調査の方向性

まず、提供されている plotly.express.histogram の例を plotly 5.18.0 で実行し、トレースを legendonly に設定した場合と、すべてのトレースを表示した場合で、facet_col と marginal の動作を比較します。marginal の box の順序がどのように生成されるかを追跡し、month 5 を表示してもカテゴリの順序 5, 6, 7 が維持されることを確認します。

索引モデルが issue の本文から書いたものです。

評価

技術スタック
python
領域
data-visualization
issue の種類
バグ
難易度
4/5
見積もり時間
3〜5日
活発さ
停滞
明瞭さ
おおむね明確
初心者へのやさしさ
35/100

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。