-
-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Adding automargin support to plot titles #6428
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
archmoj
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@hannahker very nice improvement.
Please find my comments below.
Thank you!
alexcjohnson
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Excellent, I think we finally got there! 💃
I know there's still an issue with multiline titles - as shown in the zzz-automargin-title-paper-multiline mock - but since this was already buggy before this PR we can address that in a patch.
|
This is so good for multiline titles, thank you very much! |
This pull request adds 'automargin' support for
layout.titlecomponents. Iflayout.title.automargin=true, then either the top or the bottom margin space will expand such that the plot title is visible in the plotting area.To-dos:
title.automarginlayout.title.ytitle.y=1andtitle.yref='paper'defaults whentitle.automargin=true(insupplyDefaultsstage)yanchoryref='paper'yref='paper'yref='container'yref='container'title.yanchor#6472yref='paper'API Questions:
Should
title.automarginsupport multi-line titles? Looking at this codepen, there seem to be some issues with multi-line positioning, see Multi-line titles don't respond totitle.yanchor#6472A: Currently out of scope given existing bug.
Should
title.automarginallow the title to overlap with the plot itself? Or doestitle.automarginonly ensure that the title is visible? Ex. what iftitle.y=0.6? Should the margin then expand to take up the top 40% of the plot area?A: This depends on
title.yref. When the title is'paper'referenced, thentitle.automargincan't do anything to impact potential overlap with the plot area, as the plot area is also'paper'referenced. When the title is'container'referenced, thentitle.automarginwill increase the top or bottom margin to avoid overlap with the plot area.If a developer manually specifies
title.yref='container'andtitle.automargin, then which one 'wins'?A: N/A. In this case
title.automarginwill have an impact.layout.title.y=1+layout.title.yanchor='bottom'/layout.title.y=0+layout.title.yanchor='top--> shouldautomarginhandle these cases so that the title is visible? Logically, I don't think it should be.A: Assuming that
title.yref='container', the title should not be visible in these cases as it is outside of the plot area. Iftitle.yref='paper', then this would be a common way to pin the title to either the top or bottom of the plot area.What if
layout.title.y='auto'and there isn't enough manually-defined top margin to fit the title? (ref: ""auto" places the baseline of the title onto the vertical center of the top margin"). Should we add in logic here so that the top margin will expand to 2x the size of the title? It doesn't seem intuitive to the developer in this case that the top margin will have this artificial padding.A: When
title.automargin=true, we can set the defaulttitle.y=1, which is a more logical default and would avoid this behaviour.How will
title.automarginbehaviour be different whenyref='container'vsyref='paper'?A: If
yref='container', thentitle.automarginwill push margins to ensure that the title doesn't overlap with the plot area. Ifyref='paper', thentitle.automarginwill only push margins to ensure that the title doesn't overlap with the edges of the container.Should
title.automarginpotentially push out the left or right margins?A: No, this implementation will only support spacing added to top or bottom margins.
Technical Questions:
xandyinput parameters to thePlots.autoMarginfunction be specified? I would expect that these would be justtitle.xandtitle.y. In testing, seems only to work whenyis1or0. (ref: "x, y: plot fraction of the anchor point.")title.automarginapplies bottom margin as well as the x-axis?