My speculation is that the text box always abuts the right hand side of the legend item, but that the text box width is left unspecified so it auto sizes to exactly the text width. In that case, “centering” means centering inside a box exactly the width of the text which is not so useful. It’s possible that we can set the text box width explicitly to the width of the legend area instead, so that centering would be useful here. But I don’t have any immediate workarounds or suggestions except to submit a GitHub Issue with full details.
Edit: looking at the code maybe it’s not exactly that but still seems like a bug to report in any case.
Thank you for your reply Bryan, it’s given me an idea for a really rough workaround.
For instance, in the above example, making three separate Legends and adding them manually by calculating their position.
Since each Legend only contains the LegendItem, it will be centered horiziontally.
Obviously extremely inelegant and inefficient, but it’s a brute force method to do what I want
p.text(text=title)
Legend1 = Legend(items=[LegendItem1])
Legend2 = Legend(items=[LegendItem2])
Legend2 = Legend(items=[LegendItem3])
#Calculate each Legend position (x,y) and add them manually to the figure
If I come up with an elegant workaround, I’ll post it here!