-
Notifications
You must be signed in to change notification settings - Fork 2.1k
Calculate constant descender heights, regardless of label content. #2471
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
I have updated the themes. Visual changes are minimal at the default font size but larger for larger or smaller font sizes, because all fixed lengths have been replaced by relative lengths. I also fixed a bug with excessive spacing underneath multi-line titles for legends. (The spacing is now based on the font size specified in the theme, and therefore doesn't care about multiple lines.) For Some examples of figures made with these changes:
The same plot with current ggplot2 for comparison. The main difference can be seen in the spacing between the legend title and the legend key for the colorbar legend. Finally, I've changed the font size of the subtitle and caption, to unify font sizes used. Here is the result.
|
…s been set to element_blank())
This comment has been minimized.
This comment has been minimized.
@clauswilke do you mind having another go with the dev version of vdiffr? (You'll need to run |
Please let me know if anything is unclear - the visual tests are a bit more work, but they're really valuable for preventing regressions that are otherwise hard to test for. |
Yes, I completely agree with you on visual tests. I just installed the latest version of ggplot2 and vdiffr and I managed to successfully pass all current visual tests. So I should be able to fix them for this patch. |
Great news! |
Yay for visual testing. I've found a problem I need to fix. Descender heights are not applied to vertical facet strips. I'll need to do some digging to figure out where the fault lies.
|
I've only looked quickly but I think the problem is here: Line 75 in d0a2929
The angle of the "dummy strip" text is 270, making library("ggplot2")
ggplot(iris, aes(Sepal.Length, Sepal.Width)) +
geom_point() +
facet_grid("dummy strip" ~ Species) # vertical strip is still narrower Created on 2018-04-30 by the reprex package (v0.2.0). |
@karawoo good catch!! |
@karawoo Thanks! I was suspecting this line, but I'm not very good with trigonometry in my head. :-) I'll find a fix. |
I have fixed the issue (a simple All tests pass on my system:
|
Thanks! (For future reference, no need to include the tests results because (a) I trust you and (b) travis will check too) |
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/ |
This pull request fixes #2288, by calculating descender height in
titleGrob()
on a fixed string rather than based on the specific label string handed totitleGrob()
.This commit causes subtle changes to all ggplot2 output, because it changes the height of axis tick labels and of legend titles as well as plot titles, plot subtitles, etc. I have looked through all visual tests and I didn't see any breakage. I also rebuilt my book with this patch and found no problems. However, the spacing between x-axis tick labels and the x-axis title, or between legend title and legend, is now arguably a little too large, and some small tweaks to themes might be warranted.
In a similar vein, with this fix, the default
vgap
value calculated here and here is arguably a little too large. A coefficient of 0.4 might work better.I didn't accept the visual tests because for some subset of tests the svgs on my computer have never agreed with the ones in the repository.