Via Python, I am using Altair to plot bar graphs. I was able to move the legend to be at the top, however, it is adding ellipsis (i.e. "...") at the end of each legend because my strings are too long. Is there any work around this? I tried gradientlength
but it does not do the trick. Also, and as my strings are pretty long, would be possible to jump lines between each legend?
alt.Chart(df).mark_bar().encode(
x=alt.X("fund:O", axis=alt.Axis(title=None, labels=False, ticks=False)),
y=alt.Y("value:Q", axis=alt.Axis(title="Percentage", grid=True)),
color=alt.Color("fund:N", legend=alt.Legend(orient="top")),
tooltip=["data point info:O", "fund:N", "value", "bucket"],
column=alt.Column(
"bucket:N",
header=alt.Header(title=None, labelOrient="bottom", labelAngle=x_angle),
sort=list_to_sort,
spacing=40,
),
).configure_view(stroke="transparent").interactive()
This is how it current looks like:
One example of the legends is:
- "Morningstar - FOUSA08OZU: Vanguard Total Bond Market II Index Fund Institutional Shares"
Documentation is here - https://altair-viz.github.io/user_guide/generated/core/altair.Legend.html
Similar ish question - Changing Size of Legend in Altair