Repository navigation
Replies: 1 comment 2 replies
|
Yes. In a faceted chart each column gets its own copy of the x axis, and each copy sits in a group that knows its column value as chart = alt.Chart(df).mark_bar().encode(
x=alt.X("P:N", axis=alt.Axis(titleOpacity=alt.expr("parent.C == 100 ? 1 : 0"))),
y=alt.Y("Max:Q", title=None),
color="P:N",
row=alt.Row("T:N", title=["Maximum Long Word Observed (units)", "", "T"]),
column="C:N",
).properties(width=100, height=100)
Use your own column field in place of Simpler, but not quite centered: drop the axis title and add a title at the bottom of the chart: x=alt.X("P:N", title=None)
# ...
chart = chart.properties(title=alt.TitleParams("P", orient="bottom", anchor="middle"))It centers on the whole chart, including the legend and the row title, so here it lands about 20 px left of the middle column. How I checked: I used Altair 6.0.0 (Vega-Lite 6.1) and the MWE from #2666 with its accepted row-title trick. I rendered each variant to PNG with vl-convert and looked at the images:
Not tested: the Jupyter / browser renderer (it's the same Vega engine, but I only rendered with vl-convert), and Altair versions older than 6.0.0. |
Uh oh!
There was an error while loading. Please reload this page.
Hey - basically in this question/discussion here: is there a way to have a single x-label so basically just one "P" either in the center or maybe in the leftmost column? thanks!!
All reactions