-
Notifications
You must be signed in to change notification settings - Fork 796
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
sort
argument doesn't sort categories/colors in stacked bar
#1987
Comments
The The docs on the Altair side, as always, could be improved. |
The y encoding's |
Ok, I think I see what you mean. A simple way to order stacked bars that accepts an array would be more intuitive (and easier) but it seems that's a Vega-Lite limitation. As always, thanks for all the effort! |
I believe this issue tracks the functionality you want. |
I came across this 'issue' (perhaps not a issue, but a feature in vega-lite), as suggested above, a work around is to assign a new order column with quantitative values after preprocess with whatever required order in dataframe: a quick example:
(recall above comments that sort is applying to axis, e.g the legend name follow that specified 'sort=', the actual bar follows 'order=') further ref: |
There are several places indicating that the argument
sort
can be used universally to set a custom ordering by passing an array (list) with the desired order. This works for categories on the x-axis of a grouped bar chart but not the y-axis.Current versions:
Example (vega-lite spec):
I did, however, find a workaround by ordering according to a new indexing column (vega-lite spec):
I'm not sure if this is a bug in vega-lite, an oversight in the API, or the way that it is supposed to work, but I'm providing this example and my work-around to help anyone else who might be searching for for help with the same issue.
The text was updated successfully, but these errors were encountered: