-
Notifications
You must be signed in to change notification settings - Fork 2k
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
ggtitle height varies with descending letters #2288
Comments
There isn't unfortunately 😞 |
I've run into this problem also and I debugged it in quite some detail. I'm writing up my findings here in the hope they may be useful to somebody. I don't have the time right now to prepare a proper pull request but may be able to do so in the future. The problem is caused by this line: Line 73 in bef2f38
The function
A simple fix would be to replace the string in the text grob with a constant string that is always used. This should return the same descent height at all times, only dependent on font metrics and independent on the specific label used. So, we could replace this line:
with these two lines:
to get consistent descent values regardless of the text label shown in the plot. |
Here's the effect of this proposed patch. Example 1:
Example 2:
Note that this also fixes the layout of the legend title. |
…2471) * Calculate constant descender heights, regardless of label content. Fixes #2288 * Make themes more visually consistent. Also fix spacing bug for multi-line legend titles. * gracefully handle missing fontsize in theme (e.g., if legend.title has been set to element_blank()) * update vdiffr templates
This old issue has been automatically locked. If you believe you have found a related problem, please file a new issue (with reprex) and link to this issue. https://reprex.tidyverse.org/ |
Hi there,
I just noticed that the height of a ggplot2 main title depends on the letters used. Although there is no difference in the title height (and therefore the dimensions of the plot itself) between titles with only typical sized letter (e.g. "arrr") or with ascenders (e.g. "brrr"), the title height increases with the inclusion of descenders (e.g. "prrr"). Although I understand that as a workaround I can use all-caps or readjust the plot height with
ggplotGrob
, I wonder whether I missed a parameter (withintheme
?) that could fixate the title height independent on the letters used.Thanks in advance!
The text was updated successfully, but these errors were encountered: