Search code examples
pythonchartsvisualizationaltairvega-lite

Altair make axis lines thicker


I have an altair chart that looks like below. I would like to make the axis lines thicker as I (read: the reviewer of my paper) feel the current lines are too thin and are not easily visible on the screen. I tried looking at the Top-Level Chart Configuration, but I couldn't find anything that would allow me to do that. The closest thing I found that to use .configure_view(strokeWidth=4, stroke='black'), that makes the entire chart border thicker but I want just the axis lines to be thicker.

How do I make the axis lines thicker? Any help is appreciated.

enter image description here


Solution

  • It is controlled by domainWidth. e.g.

    import altair as alt
    from vega_datasets import data
    
    source = data.movies.url
    
    alt.Chart(source).mark_bar().encode(
        alt.X("IMDB_Rating:Q", bin=True, axis=alt.Axis(domainWidth=10)),
        y='count()',
    )