Reputation:
This is the chart I've created:
But this is what I want it to look like:
The title for "Top Third" is not centered where it should be but when I try to adjust the title alignment, I get an error that I can't use configuration with hconcat. This is the partial code for the visualization:
chart_top = (text_top + bars_top).properties(
width=80,
height=180,
title="Top third",
)
chart_middle = (text_middle + bars_middle).properties(
width=80,
height=180,
title="Middle third",
)
chart_bottom = (text_bottom + bars_bottom).properties(
width=80,
height=180,
title="Bottom third",
)
merge = alt.hconcat(chart_top, chart_middle, chart_bottom).configure_scale(
bandPaddingInner=0.2
).configure_view(
strokeWidth=0
).properties(
title={"text":["How People Rate the 'Star Wars' Movies"],
"subtitle":["How often each film was rated in the top, middle and bottom third",
'(by 471 respondents who have seen all six films)']}
).configure_title(
fontSize=24, align='left', fontWeight='bold', anchor="start", subtitleFontWeight='lighter'
).configure_axis(
labelFontSize=14)
alt.themes.enable('fivethirtyeight')
merge
Upvotes: 0
Views: 520
Reputation: 48934
You can use alt.TitleParams
on the left most chart with either dx
to manually set the offset or anchor=end
to right align:
chart_top = (text_top + bars_top).properties(
title=alt.TitleParams("Top third", dx=100))
You could also create an empty chart just holding the labels.
Upvotes: 1