-
Notifications
You must be signed in to change notification settings - Fork 2.1k
Use rel() more consistently in theme elements, take two #2173
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
R/theme-defaults.r
Outdated
@@ -134,7 +134,7 @@ theme_grey <- function(base_size = 11, base_family = "") { | |||
panel.background = element_rect(fill = "grey92", colour = NA), | |||
panel.border = element_blank(), | |||
panel.grid.major = element_line(colour = "white"), | |||
panel.grid.minor = element_line(colour = "white", size = 0.25), | |||
panel.grid.minor = element_line(colour = "white", size = rel(0.25)), |
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.
I noticed that these actually change the values of the width as the base_size
(as far as I can tell) is set to 0.5 by line
. I think that means all the values inside rel()
should be doubled.
It also suggests that before merging this PR we should make some basic visual tests for the themes.
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.
Ooops, should've refreshed before commenting. Glad the tests picked this up! (Although I'm not sure what went wrong on travis)
I doubled the values inside |
Tests failed on travis but not on appveyor, this is similar to #2080. |
R/theme-defaults.r
Outdated
@@ -204,15 +204,15 @@ theme_linedraw <- function(base_size = 11, base_family = "") { | |||
theme_bw(base_size = base_size, base_family = base_family) %+replace% | |||
theme( | |||
# black text and ticks on the axes | |||
axis.text = element_text(colour = "black", size = rel(0.8)), | |||
axis.ticks = element_line(colour = "black", size = 0.25), | |||
axis.text = element_text(colour = "black", size = rel(1.6)), |
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.
I think this should stay as is since it was already in a rel()
?
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.
Whoops yes, will change it back.
@karawoo do you mind doing a separate PR that ensures that there's one visual test for each theme that's bundled with ggplot2? Then we can re-run this on top of that, and be confident that we haven't changed anything accidentally. |
My original reason to look at this piece of source code and notice inconsistencies was triggered by a small plot in the margin of a Tufte-style document that looked quite bad/disproportionate. I think it may be worth setting up visual tests for a couple of different plot sizes, e.g. i) a 4x3 inches figure with 11pt font etc. for a typical publication, ii) a 24pt font, bold lines, 8x4in plot for a powerpoint, iii) a small inset-style / margin figure with 9pt font and thin lines. (last time I looked, some themes had a few default aesthetics that I found visually suboptimal at small sizes): |
Small plots (e.g. in the margins of tufte-style books) tend to look heavy with the current linewidth settings, and after investigating I noticed some inconsistencies in the use of `rel()`.
I rebased these changes now that we've got the new test from #2174. |
NEWS.md
Outdated
@@ -1,5 +1,7 @@ | |||
# ggplot2 2.2.1.9000 | |||
|
|||
* Uses `rel()` more consistently in theme defaults (@baptiste). |
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.
I think you can be a bit more explicit: use rel()
to set line widths in theme defaults.
This discussion got me thinking about an analogy to optical sizes for rendering fonts, whereby different characters undergo minute changes in specific size ranges, to improve legibility and aesthetics. I wonder if the theme system couldn't use a similar strategy to adjust line widths, font sizes, perhaps even colour and fills, depending on a global parameter (plot size is what comes to mind). In another aspect,
|
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 is the continuation of #1883. Includes @baptiste's changes plus a line in
NEWS.md
about the change.