custom sorting categorical axis with layers - working in VL3 Editor
See original GitHub issueHi Jake,
Not sure if you’ve seen the recent slack discussion on this but I wanted to let you know that the following works in the VL3 Editor but not in Altair. I’m referring to the sorting of the Y axis labels.
df=pd.DataFrame({'Org': ['school','school','school','school', 'board', 'board', 'board', 'board'],
'variable': ['rose', 'dropped', 'maintained', 'failed','rose', 'dropped', 'maintained', 'failed'],
'percent': [25,25,25,25,25,25,25,25],
'position': [12.5, 37.5,62.5, 87.5,12.5, 37.5,62.5, 87.5]})
bars=alt.Chart().mark_bar().encode(
x=alt.X('sum(percent)', title='Percentage of Students'),
y=alt.Y('Org', sort=['school'], title=None),
color=alt.Color('variable', title=None),
order='junk:Q'
)
text=alt.Chart().mark_text(align='center', baseline='middle').encode(
y=alt.Y('Org', sort=['school'], title=None),
x='position',
text='percent')
alt.layer(bars, text, data=df).transform_calculate(
junk="if(datum.variable === 'maintained', 0, if(datum.variable === 'rose', 1, if(datum.variable === 'dropped', 2, 2)))")
The VL folks showed me how to get this working and I thought perhaps it would translate to Altair 2.2. I assume it is simply a VL2 versus VL3 difference but wanted to bring it to your attention in case it is helpful for you to know.
Issue Analytics
- State:
- Created 5 years ago
- Comments:7 (4 by maintainers)
Top Results From Across the Web
8.4 Changing the Order of Items on a Categorical Axis
For a categorical (or discrete) axis – one with a factor mapped to it – the order of items can be changed by...
Read more >Altair Stacked Area With Custom Sorting
For line and trail marks, this property determines the sort order ... sorting categorical axis with layers - working in VL3 Editor hot...
Read more >Untitled
#tans Zedd e hayley letra, Dc brushless motor working principle. ... X edit digitech windows 7, Nvidia shield kodi 16, Neem tree buy?...
Read more >Untitled
Kaan work mp3, Fan milk lagos nigeria, Nicholas goodden street photography, ... Turismo culturale in grecia, Matschig englisch, Custom 338 bullets!
Read more >GPU Applications Catalog
Custom models and data streams. Multi-GPU. Single Node ... work of business analysis, empowering ... Provides a list of matches sorted by confidence....
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
As of v2.3.0 with VL 3, axes may now be sorted by passing a custom sort array to the channel as such:
In the ‘bars’ chart, for the y put this:
That now sorts ‘board’ before ‘school’ on the y-axis.