Issue #303 margin adjustment for multi-line labels and titles#549
Issue #303 margin adjustment for multi-line labels and titles#549vincentarelbundock wants to merge 7 commits intograntmcdermott:mainfrom
Conversation
|
Super, thanks for taking this on. I kept meaning to, but couldn't find the time... |
|
Frankly, I'm not sure I can wrap my head entirely around the margins part of the code. But this seems to be working for the cases I investigated. So I'd say this is OK for review. |
grantmcdermott
left a comment
There was a problem hiding this comment.
Left a few quick comments while I had a sec.
I also have a slightly more involved refactor in mind for the core dynamic theme margin adjustment logic. tl;dr Right now, we do things a bit back to front; we assign title space up front and then remove it if it is absent, or increase if it has multiple lines per your PR here. I think we could simplify things for these dnymaic themes, by setting margins that assume no titles a priori and then make (multline) space for them if these titles are present. I'll take a crack at this later today, hopefully.
| left_margin_in = par("mai")[2] | ||
| # Keep roughly one glyph-width of room from the left device edge to avoid | ||
| # clipping of the outermost ylab line on compact multi-panel layouts. | ||
| edge_pad_in = 0.75 * csi * cex_ylab |
There was a problem hiding this comment.
I might be misunderstanding, but why calculate in inches (csi) instead of user coords (cxy)?
Where does 0.75 come from? Is it borrowed from one of the (hard-coded) based plot scaling factors? Or, just eye-balling?
There was a problem hiding this comment.
just eye-balling. Maybe we can come up with a better rule.
There was a problem hiding this comment.
TBH I'm a little nervous about this. But I'm also not going to be able to look at it again for at least another fortnight (and probably a bit longer), since I've got some major work deadlines to finish before heading out on vacation next week.
Having said that, the plots generally look good to me. If you're comfortable with the current progress and would like to merge as-is---with the idea that we could fix some of these remaining idiosyncrasies in a later PR---then I can get onboard with that. Otherwise, happy to sync up again in March.
…plot into pr/vincentarelbundock/549
|
Thanks for this. I'm completely snowed ATM and didn't get around to implementing the full margin-logic refactor that I mentioned above, i.e.
But... I did at least implement a |
|
I'm not in a rush at all, and TBH I don't understand this code super well. Probably best to wait. |
This change fixes dynamic margins when annotation text is missing (
NA,NULL, or empty) and when labels contain multiple lines.Internal changes:
text_line_count()to normalize line counting for labels/subtitles (treat missing text as 0 lines).main/sub/xlab/ylabinto facet margin logic and adjusted margins by line count (shrink for missing text, expand for multi-line text).subin legend layout, sosub = NAno longer reserves extra bottom space.Testing note: