Skip to content

How to set a proportional bar width that scales nicely? #2601

Answered by mattijn
quantoid asked this question in Q&A
Discussion options

You must be logged in to vote

Once the next version of Altair is released you can use width=alt.RelativeBandSize(0.7). Using the main repo of altair this gives me currently:

import altair as alt
from vega_datasets import data

source = data.seattle_weather()

alt.Chart(source).mark_bar(
    width=alt.RelativeBandSize(0.7)
).encode(
    x='month(date):O',
    y='mean(precipitation):Q'    
)

Replies: 2 comments 5 replies

Comment options

You must be logged in to vote
2 replies
@quantoid
Comment options

@quantoid
Comment options

Answer selected by quantoid
Comment options

You must be logged in to vote
3 replies
@quantoid
Comment options

@DanielFortuyn
Comment options

@joelostblom
Comment options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
4 participants