Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

fix: custom category order was hard-coded #5000

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
emilykl merged 2 commits into plotly:master from MarcoGorelli:hardcoded-var
Jan 30, 2025

Conversation

@MarcoGorelli
Copy link
Contributor

@MarcoGorelli MarcoGorelli commented Jan 30, 2025
edited
Loading

closes #4999

FBruzzesi reacted with heart emoji FBruzzesi reacted with rocket emoji
@MarcoGorelli MarcoGorelli marked this pull request as ready for review January 30, 2025 09:22
"On Route",
"Delivered",
]

Copy link
Contributor

@FBruzzesi FBruzzesi Jan 30, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was doing a similar fix 🙈

You could also add the comparison with go.Pie:

 values_ = np.array([
 x[0] for x in sorted(zip(data["count"], data["status"]), key=lambda t: custom_order.index(t[1]))
 ])
 trace = go.Pie(
 values=values_,
 labels=custom_order,
 )
 _compare_figures(trace, fig)

MarcoGorelli reacted with thumbs up emoji MarcoGorelli reacted with heart emoji
Copy link
Contributor Author

@MarcoGorelli MarcoGorelli Jan 30, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yup, thanks for reviewing!

FBruzzesi reacted with heart emoji
nw.col("b")
.replace_strict(order, range(len(order)), return_dtype=nw.UInt32)
nw.col(names)
.replace_strict(order, np.arange(len(order)), return_dtype=nw.UInt32)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@MarcoGorelli What's the reason for using np.arange here rather than range? Is there a performance difference?

Copy link
Contributor Author

@MarcoGorelli MarcoGorelli Jan 30, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes, @FBruzzesi had noted that it was generally more performant, and numpy is still required in plotly express anyway - no objections to changing this back of course!

emilykl reacted with thumbs up emoji
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yup, makes sense to me, thanks!

Copy link
Contributor

@emilykl emilykl left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good @MarcoGorelli , thanks for the fix. 🎉

MarcoGorelli reacted with thumbs up emoji
Copy link
Contributor Author

thanks for your review!

emilykl reacted with rocket emoji

@emilykl emilykl merged commit d974535 into plotly:master Jan 30, 2025
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@emilykl emilykl emilykl approved these changes

+1 more reviewer

@FBruzzesi FBruzzesi FBruzzesi left review comments

Reviewers whose approvals may not affect merge requirements

Assignees

No one assigned

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

px.pie raises ColumnNotFoundError when names and category_order is passed at the same time on plotly 6.0.0

AltStyle によって変換されたページ (->オリジナル) /