Closed jonocarroll closed 4 years ago
I'm sorry I didn't respond to your initial posting. What I was thinking about on Twitter was when I'm prepping a figure for a presentation and I just want to bump up the base_size so that everything gets bigger together. At least I think that's how it works, every time I try and do it I have to look it up. I think it's base_size that way everything else scales from there. I've looked very briefly here: https://github.com/jonocarroll/ggeasy/blob/feature/text_size/R/text.R and it didn't look like you were using base size, but perhaps you've got it covered with rel or something?
This PR lets you set the size for each component (or all of them) explicitly. It looks like base_size = 11
for most themes. I could add a shortcut to modify base_size
if you think there's some relative scaling involved.
For p1 <- ggplot(mtcars, aes(hp, mpg)) + geom_point()
,
p1 + theme_grey(base_size = 15)
and
p1 + theme_grey() + easy_change_text(c("text", "title"), "size", 15)
appear to give the same results visually, with some odd scaling happening.
I can work on getting my functions to be more consistent with that output.
It looks like the theme_*
functions accept a base_size
argument then pass that on to the individual components (with various rel
components). That means it doesn't generalise outside of an individual theme. The implementation I have will allow you to specify some or all of the specific sizes.
Merging #34 into master will not change coverage. The diff coverage is
100%
.
@@ Coverage Diff @@
## master #34 +/- ##
=====================================
Coverage 100% 100%
=====================================
Files 5 5
Lines 138 179 +41
=====================================
+ Hits 138 179 +41
Impacted Files | Coverage Δ | |
---|---|---|
R/legend.R | 100% <100%> (ø) |
:arrow_up: |
Continue to review full report at Codecov.
Legend - Click here to learn more
Δ = absolute <relative> (impact)
,ø = not affected
,? = missing data
Powered by Codecov. Last update 286db5f...80c5fc3. Read the comment docs.
Ready to merge but I'll let it steep for a few days. Feel free to comment if you spot anything.
@bhive01 @yonicd
Text attribute adjustment:
easy_change_text()
which takes a theme element (choices:text, axis.text, axis.text.x, axis.text.y, axis.title, axis.title.x, axis.title.y, legend.text, legend.title, plot.title, plot.subtitle, plot.caption, strip.text, strip.text.x, strip.text.y
) and a theme attribute (choices:size, family, face, colour, hjust, vjust, angle, lineheight, color, margin
) and a value to set.Common (?) use-case shortcuts:
easy_all_text_color()
easy_all_text_colour()
easy_text_size()
easy_all_text_size()
easy_change_text()
easy_plot_caption_size()
easy_plot_legend_size()
easy_plot_legend_title_size()
easy_plot_subtitle_size()
easy_plot_title_size()
easy_x_axis_labels_size()
easy_x_axis_title_size()
easy_y_axis_labels_size()
easy_y_axis_title_size()
teach
options (not specific to the called function)Any other suggestions @bhive01?