question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Sort not working on alt.Y?

See original GitHub issue

Hi,

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: bart_chart_sorting

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:closed
  • Created 5 years ago
  • Comments:9 (6 by maintainers)

github_iconTop GitHub Comments

4reactions
jakevdpcommented, Sep 22, 2018

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.

1reaction
jakevdpcommented, Sep 22, 2018

See the Vega-Lite issues linked above for more information.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found