-
-
Notifications
You must be signed in to change notification settings - Fork 1.9k
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
Adding automargin support to plot titles #6428
Conversation
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!
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.title
components. 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.automargin
layout.title.y
title.y=1
andtitle.yref='paper'
defaults whentitle.automargin=true
(insupplyDefaults
stage)yanchor
yref='paper'
yref='paper'
yref='container'
yref='container'
title.yanchor
#6472yref='paper'
API Questions:
Should
title.automargin
support 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.automargin
allow the title to overlap with the plot itself? Or doestitle.automargin
only 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.automargin
can'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.automargin
will 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.automargin
will have an impact.layout.title.y=1
+layout.title.yanchor='bottom'
/layout.title.y=0
+layout.title.yanchor='top
--> shouldautomargin
handle 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.automargin
behaviour be different whenyref='container'
vsyref='paper'
?A: If
yref='container'
, thentitle.automargin
will push margins to ensure that the title doesn't overlap with the plot area. Ifyref='paper'
, thentitle.automargin
will only push margins to ensure that the title doesn't overlap with the edges of the container.Should
title.automargin
potentially push out the left or right margins?A: No, this implementation will only support spacing added to top or bottom margins.
Technical Questions:
x
andy
input parameters to thePlots.autoMargin
function be specified? I would expect that these would be justtitle.x
andtitle.y
. In testing, seems only to work wheny
is1
or0
. (ref: "x, y: plot fraction of the anchor point.")title.automargin
applies bottom margin as well as the x-axis?