I would like to change the x,y of the g-title element based on some logic. Specifically
I have particular chart sizes
I have 3 or more series to plot
My legend must go above the chart but below the chart title
I can only fit two series labels per line in the legend
So, this isn’t a problem, I can use legend groups and derive a sensible layout.legend.y value based on how many groups I have. However, with each legend group, the legend needs to move up and it covers the chart title. I’d like to also move the chart title up accordingly (change the y attribute on the <g> for the title). However I don’t see a way to set this. Is it possible? Or is there some better way to achieve my goal? Example of what I’m talking about:
I’d vote for adding x and y (along with xanchor and yanchor) attributes to layout.title - making the title position configurable the same as our other layout components.
@etienne a few questions after looking into this - changing layout.title from a string to an object (which i think is what you’re suggesting) is a breaking change right? what is your policy on that - meaning is it fine to change title to an object with text, x, y, xanchor, yanchor (maybe even font rather than having that be a separate thing) and when people upgrade, they’ll need to change accordingly?
Titles.draw seems to be called for multiple things (more than just the main title). The most straightforward approach here seems to be to put the logic for x/y/xanchor/yanchor in plot_api.drawMainTitle. Does that seem correct to you? Is referring to legend.anchor_utils from plot_api also correct? Probably moving that out of legend as its already shared by more than legend and doesn’t seem so legend specific is more correct although i’d like to try to not increase my scope of refactor too much.