Conversation
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Link to issue
Fixes #3198, fixes #3291.
Description of change
When Plotly Express splits data into several traces (e.g. via \color), plotly.js orders categories by first appearance across traces (default \categoryorder). Because each trace only carries its own rows (None-padded), that order can differ from the order in the underlying data — contradicting the documented behavior that Plotly Express lays out categorical data in the order in which it appears in the data.
This change records the data-appearance order of string categorical \x/\y\ columns in \make_figure\ (new _default_category_orders_for_axes\ helper in \plotly/express/_core.py), but only when the data is actually split into more than one trace and the user did not supply an explicit \category_orders\ entry. The existing \set_cartesian_axis_opts\ then emits \categoryorder=array\ + \categoryarray, so:
Explicit user \category_orders, single-trace figures, and numeric/datetime axes are untouched.
Testing strategy
uff==0.11.12 check\ clean.