plotly / plotly/plotly.py

category_order is not working after using facet plots

Open
#3,033 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

bug P3
Dominant language
Python
Stars
18.8k
Forks
2.8k
Avg merge
16h 26m
Merged PRs (30d)
21

Description

Hi, I don't know why but the update_yaxes with category_orders as parameters is not working after using the facet_col parameters in the plotly express bar plots.

px.bar(pe_final, x='Count', y='index', 
       color='Count', color_continuous_scale=px.colors.sequential.dense,
       orientation='h',
      text=pe_final['Count'].astype('str') + '<br>'+pe_final['Perc'].astype('str')).update_yaxes(categoryorder="total ascending")

image
This is when not using the facet col

px.bar(pe_final, x='Count', y='index', 
       facet_col='Type', 
       color='Count', color_continuous_scale=px.colors.sequential.dense,
       orientation='h',
      text=pe_final['Count'].astype('str') + '<br>'+pe_final['Perc'].astype('str')).update_yaxes(categoryorder="total ascending")

image
This is when using the facet col, and my category orders did not work.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Reproduce the two Plotly Express bar-plot examples, comparing behavior with and without facet_col='Type' and categoryorder='total ascending'. Start by tracing the update_yaxes category-order handling for faceted figures and add a regression test for the shown case. Done means the faceted plot applies the requested category order consistently.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
data-visualization
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.