Repository navigation
Facet Charts with dynamic spacing #3884
Unanswered
chrisHassan
asked this question in
Q&A
Replies: 1 comment 2 replies
|
Use a step height instead of a fixed one. With chart = alt.Chart(df).mark_image(width=30, height=30).encode(
y=alt.Y("item:N", title=None), # one category per record (see note)
url=alt.Url("image_url"),
).properties(
height=alt.Step(40), width=200, # 40 px per row instead of 200 px per facet
).facet(
row=alt.Row("facet_group", header=alt.Header(orient="top"))
).resolve_scale(
y="independent"
)I rendered your example with vl-convert (Altair 6.3) and measured the facet cell heights:
One thing to watch: with |
2 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Hi There,
I’d like to control the height of each row (facet group) in a faceted Altair chart, rather than having a uniform facet height.
In the example below, I have three groups with different numbers of rows. Each group currently renders as a facet with the same height, but I’d like each row’s height to scale based on the number of items (i.e. width per record plotted rather than per facet group).
Here’s a minimal example:
This produces a chart where each facet block has the same height, even though the number of rows (images) varies by group:
To approximate variable facet heights, I tried generating each group separately and concatenating them with a height proportional to the number of rows. This almost works - but feels a bit clunky and manual:
Is there a way:
Appreciate time and help with this :-)
All reactions