Altair: Weird label alignment in stripplot

Created on 17 Dec 2019  路  3Comments  路  Source: altair-viz/altair

I want a stripplot with the x-axis and y-axis swapped compared to the example in the documentation. When doing this, the alignment of the y-axis labels becomes a bit strange. I did not see this behaviour in Altair 3.

# Based on https://altair-viz.github.io/gallery/stripplot.html

import altair as alt
from vega_datasets import data

source = data.movies.url

stripplot =  alt.Chart(source, width=400, height=40).mark_circle(size=8).encode(
    y=alt.Y(
        'jitter:Q',
        title=None,
        axis=alt.Axis(values=[0], ticks=True, grid=False, labels=False),
        scale=alt.Scale(),
    ),
    x=alt.X('IMDB_Rating:Q'),
    color=alt.Color('Major_Genre:N', legend=None),
    row=alt.Row(
        'Major_Genre:N',
        header=alt.Header(
            labelAngle=0,
            titleOrient='top',
            labelOrient='left',
            labelAlign='right',
        ),
    ),
).transform_calculate(
    # Generate Gaussian jitter with a Box-Muller transform
    jitter='sqrt(-2*log(random()))*cos(2*PI*random())'
).configure_facet(
    spacing=0
).configure_view(
    stroke=None
)

stripplot

visualization

bug vega-lite-related

All 3 comments

This is due to a bug introduced in the most recent Vega/Vega-Lite release; see https://github.com/vega/vega/issues/2233 and https://github.com/vega/vega-lite/issues/5547

Once a fix for that is released, we'll update Altair with the fix.

Thank you for the links to the core issue.

If anybody else has problems with this you can use labelAlign='left' instead of labelAlign='right' until it is fixed in Vega.

Adding this SO post too for documentation on a similar issue and helping those who come across this.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

zanarmstrong picture zanarmstrong  路  4Comments

SuperShinyEyes picture SuperShinyEyes  路  3Comments

LukeMathWalker picture LukeMathWalker  路  3Comments

galloramiro picture galloramiro  路  3Comments

firasm picture firasm  路  3Comments