-
Notifications
You must be signed in to change notification settings - Fork 2.1k
Colorbar fixes; closes #2397 and #2398 #2415
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
This pull request will have to be modified slightly to be compatible with pull request #2471 or vice versa. I'm happy to modify either one once the other has been integrated into master. I can't easily merge the two into one, because I didn't know that I should make a separate branch when I set up this pull request. |
Would it be possible to move ahead and integrate this patch? It fixes some rather annoying bugs in |
Ooops, sorry I missed your comment and merged in a suboptimal order. This looks good to go if you want to merge/rebase, and a visual test would be lovely if you wanted to add one. |
That's fine. I'll rebase, fix the existing visual tests, and add one or two more. |
…end() and guide_colorbar(), tweak default spacings.
I rebased and added three visual tests, one for multi-line legend titles, one for custom settings of I have also carefully looked over the default settings for vertical and horizontal spacing. The original settings had two problems: (i) They were too large, in my opinion; (ii) horizontal and vertical defaults were different, which caused strange layouts in some cases. I have fixed both, but arguably have made the spaces too small. I'm happy to tweak further. Below is the current default as of this commit.
(Basically, I tried 0.5*fontsize and it was too large, and now I'm using 0.25*fontsize but it may be too small. We could use something in between, but it would be a unit that isn't anywhere else in the theme.) |
That looks a lot better, thanks! |
Can you please add a bullet to NEWS? It should briefly describe the change (starting with name of the function), and crediting yourself with |
I've changed the code so the default vgap and hgap is 0.5 * fontsize, and I've updated NEWS.md. |
Thanks! |
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 closes #2397 and #2398.
Colorbar legends work in all positions and use the same spacings as regular legends:
(I renamed the color guide as
"Petal.Width"
because this title has a different height than"Species"
, which has a descent. Without this renaming the guides don't look equivalent but that's not the fault ofguide_colorbar()
.)And gaps between the title and the colorbar can be set in horizontal and vertical contexts and the gap is of the size specified:
One problem that I see remaining is that with the default theme the legend title sits too close to the bar:
But this is a problem with how theming and title grobs work, not with the colorbar code. And the problem is the same in both
guide_colorbar()
andguide_legend()
, only that it's slightly less obvious in the latter. And the problem exists in the same form in the current ggplot2, so this is not a regression.