Sort not working on alt.Y?
See original GitHub issueHi,
Trying to sort a bar chart on another field, not getting the expected results.
My data in DataFrame:
location name score sort_order target
0 A Elwood Dempsey 10 1 20
1 B Migdalia Mcferron 23 2 25
2 B Takisha Rodiguez 32 2 25
3 C Aurea Heinecke 34 3 30
4 A Sofia Donofrio 5 1 20
5 B Cecile Eubanks 56 2 25
6 D Haley Curfman 23 4 40
7 A Keenan Israel 44 1 20
8 B Bethanie Nicosia 9 2 25
9 C Dominga Sterns 4 3 30
My Altair code to display a bar chart:
alt.Chart(data).mark_bar().encode(
alt.Y('name:N', sort= {"op": "distinct", "field": "sort_order:O"}),
alt.X('score:Q'),
color={"field": 'location:N', "sort": {"op": "distinct", "field": "sort_order:O"}}
)
Result:
The legend is sorted correctly on sort_order
, however Y isn’t sorted at all. Y is displayed in the order from the datasource. If I remove the Y sort attribute, Y is sorted alphabetically (as expected).
Question: is this a bug of I’m missing something?
Issue Analytics
- State:
- Created 5 years ago
- Comments:9 (6 by maintainers)
Top Results From Across the Web
Altair: not sorting an axis - python - Stack Overflow
This will produce a bar chart, but I do not want the x-axis categories sorted. They need to appear in the same order...
Read more >altair.Y — Altair 4.2.0 documentation
For discrete fields, sort can be one of the following: - "ascending" or "descending" – for sorting by the values' natural order in...
Read more >Sorting labeled bar charts - Google Groups
How do I sort the bars and include labels? My attempt: ```. import altair as alt. import pandas as pd.
Read more >Keyboard shortcuts for Access - Microsoft Support
Go to the Database Tools tab. Alt+Y, 2. Go to the Table tab. Alt+J, T ... Note: This shortcut does not work under...
Read more >CTRL + ALT + Y/U not working - Avid Community
I am trying to insert tracks but the commands don't work for me anymore. When I press CTRL + ALT + Y or...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Sorting layered charts does not work because of a bug in Vega-Lite. I believe it will be fixed in the Vega-Lite 3.0 release, which will be supported by Altair version 3.0.
See the Vega-Lite issues linked above for more information.