Skip to content

Ordering of columns in FacetChart #3481

Closed
vega/vega-lite
#9818

Description

@liquidcarbon

What happened?

I've been trying to lay out a chart with rows and columns where some of the values are missing, and ran into the problem of sort argument to alt.Column not working as expected.

without sorting

df = pd.DataFrame({
    'row': [1,1,1,2,2],
    'column': list('ABCAB'),
    'x': [1,2,3,4,5],
    'y': [1,2,3,4,5],
})

alt.Chart(df).mark_circle().encode(
    x='x',
    y='y',
    row='row',
    column=alt.Column('column')
).properties(width=120, height=80)

image

with sorting - incorrect order

alt.Chart(df).mark_circle().encode(
    x='x',
    y='y',
    row='row',
    column=alt.Column('column', sort=list('ABC'))
).properties(width=120, height=80)

image

Why would the bottom row shift? Is it a bug?

What would you like to happen instead?

proper sorting

Which version of Altair are you using?

5.3.0

Activity

  1. joelostblom commented on Jul 17, 2024

    @joelostblom
    Contributor

    This looks like it could be due to the underlying Vega-Lite issue, probably this one vega/vega-lite#8675. Feel free to add your example there if you think it is the same issue or comment here if it isn't and we can troubleshoot further here.

  2. liquidcarbon commented on Jul 17, 2024

    @liquidcarbon
    Author

    Thanks for your response.
    One common theme between the calendar example in vega/vega-lite#8675, this toy example here, and the real thing I was trying to do:

    Within the row with missing columns, the remaining values are pushed to the right. Very odd!

  3. added a commit that references this issue on Jul 22, 2026
    a29b4ef
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions