From 8f8b1f098d02329632fff26a89083237fa8cc75f Mon Sep 17 00:00:00 2001 From: hrbrmstr Date: Sat, 10 Jul 2021 08:36:19 -0400 Subject: [PATCH] textbox_simple and margin tweaks --- DESCRIPTION | 4 +-- NEWS.md | 4 +++ R/finish-theme.R | 87 ++++++++++++++++++++++++++++++++++++++---------------- R/theme-gs.R | 2 +- R/theme-inter.R | 2 +- R/theme-rc.R | 2 +- README.md | 4 ++- man/theme_gs.Rd | 2 +- man/theme_inter.Rd | 2 +- man/theme_rc.Rd | 2 +- 10 files changed, 77 insertions(+), 34 deletions(-) diff --git a/DESCRIPTION b/DESCRIPTION index f42d184..8a7c9f8 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -2,8 +2,8 @@ Package: hrbragg Type: Package Title: Typography-centric Themes, Theme Components, and Utilities for 'ggplot2' and 'ragg'. -Version: 0.2.1 -Date: 2021-05-20 +Version: 0.2.2 +Date: 2021-07-10 Authors@R: c( person( given = "Bob", diff --git a/NEWS.md b/NEWS.md index 9b4679b..d81204a 100644 --- a/NEWS.md +++ b/NEWS.md @@ -1,2 +1,6 @@ +0.2.2 +* title/subtitle/caption are now `ggtext::element_textbox_simple()` +* minor margin tweaks + 0.1.0 * Initial release diff --git a/R/finish-theme.R b/R/finish-theme.R index 066bc38..88aaf71 100644 --- a/R/finish-theme.R +++ b/R/finish-theme.R @@ -166,43 +166,69 @@ finish_theme <- function(base_size, theme( axis.title = element_text( size = axis_title_size, - family = axis_title_family, lineheight = line_height + family = axis_title_family, + lineheight = line_height, + margin = margin(t = axis_title_size/2) ), axis.title.x = element_text( hjust = xj, size = axis_title_size, - family = axis_title_family, lineheight = line_height + family = axis_title_family, + lineheight = line_height ), axis.title.x.top = element_text( - hjust = xj, size = axis_title_size, - family = axis_title_family, lineheight = line_height + hjust = xj, + size = axis_title_size, + family = axis_title_family, lineheight = line_height, + margin = margin(b = axis_title_size/2) ), axis.title.x.bottom = element_text( - hjust = xj, size = axis_title_size, - family = axis_title_family, lineheight = line_height + hjust = xj, + size = axis_title_size, + family = axis_title_family, + lineheight = line_height, + margin = margin(t = axis_title_size/2) ), axis.title.y = element_text( - hjust = yj, size = axis_title_size, - family = axis_title_family, lineheight = line_height + hjust = yj, + size = axis_title_size, + family = axis_title_family, + lineheight = line_height, + margin = margin(r = axis_title_size/2) ), axis.title.y.left = element_text( - hjust = yj, size = axis_title_size, - family = axis_title_family, lineheight = line_height + hjust = yj, + size = axis_title_size, + family = axis_title_family, + lineheight = line_height, + margin = margin(r = axis_title_size/2) ), axis.title.y.right = element_text( - hjust = yj, size = axis_title_size, angle = 90, - family = axis_title_family, lineheight = line_height + hjust = yj, + size = axis_title_size, + angle = 90, + family = axis_title_family, + lineheight = line_height, + margin = margin(l = axis_title_size/2) ), strip.placement = strip_placement, strip.text = element_text( - hjust = 0, size = strip_text_size, color = foreground_colour, - family = strip_text_family, lineheight = line_height + hjust = 0, + size = strip_text_size, + color = foreground_colour, + family = strip_text_family, + lineheight = line_height, + margin = margin(b = strip_text_size/2) ), strip.text.x = element_text( - hjust = 0, size = strip_text_size, color = foreground_colour, - family = strip_text_family, lineheight = line_height + hjust = 0, + size = strip_text_size, + color = foreground_colour, + family = strip_text_family, + lineheight = line_height, + margin = margin(b = strip_text_size/2) ), strip.background = element_rect( fill = background_colour, color = NA @@ -214,25 +240,36 @@ finish_theme <- function(base_size, fill = background_colour, color = NA ), strip.text.y = element_text( - hjust = 0, size = strip_text_size, color = foreground_colour, - family = strip_text_family, lineheight = line_height + hjust = 0, + size = strip_text_size, + color = foreground_colour, + family = strip_text_family, + lineheight = line_height, + margin = margin(l = strip_text_size/2) ), + panel.spacing = panel_spacing, panel.background = element_rect(color = NA, fill = background_colour), + plot.background = element_rect(color = NA, fill = background_colour), plot.title.position = plot_title_position, plot.margin = plot_margin, - plot.title = element_text( - hjust = 0, size = plot_title_size, margin = margin(b = plot_title_margin), + plot.title = ggtext::element_textbox_simple( + hjust = 0, size = plot_title_size, + margin = margin(b = plot_title_margin), family = plot_title_family, lineheight = line_height ), - plot.subtitle = element_text( - hjust = 0, size = subtitle_size, margin = margin(b = subtitle_margin), + plot.subtitle = ggtext::element_textbox_simple( + hjust = 0, size = subtitle_size, + margin = margin(b = subtitle_margin), family = subtitle_family, lineheight = line_height ), - plot.caption = element_text( - hjust = 1, size = caption_size, margin = margin(t = caption_margin), - family = caption_family, lineheight = line_height + plot.caption = ggtext::element_textbox( + hjust = 1, + size = caption_size, + margin = margin(t = caption_margin), + family = caption_family, + lineheight = line_height ), ) -> ret diff --git a/R/theme-gs.R b/R/theme-gs.R index 8e60a71..220c133 100644 --- a/R/theme-gs.R +++ b/R/theme-gs.R @@ -65,7 +65,7 @@ theme_gs <- function( strip_text_size = 12, strip_placement = "outer", caption_size = 10, - caption_margin = 10, + caption_margin = 12, axis_text_size = base_size, axis_title_size = 10, axis_title_just = "rt", diff --git a/R/theme-inter.R b/R/theme-inter.R index 1c29115..3e4961c 100644 --- a/R/theme-inter.R +++ b/R/theme-inter.R @@ -65,7 +65,7 @@ theme_inter <- function( strip_text_size = 12, strip_placement = "outer", caption_size = 9, - caption_margin = 8, + caption_margin = 11, axis_text_size = base_size, axis_title_size = 9, axis_title_just = "rt", diff --git a/R/theme-rc.R b/R/theme-rc.R index 4653d6a..ae5a925 100644 --- a/R/theme-rc.R +++ b/R/theme-rc.R @@ -65,7 +65,7 @@ theme_rc <- function( strip_text_size = 12, strip_placement = "outer", caption_size = 9, - caption_margin = 10, + caption_margin = 12, axis_text_size = base_size, axis_title_size = 9, axis_title_just = "rt", diff --git a/README.md b/README.md index 2a72ee8..a722c23 100644 --- a/README.md +++ b/README.md @@ -7,7 +7,9 @@ by](https://img.shields.io/badge/Keybase-Verified-brightgreen.svg)](https://keyb ![Signed commit %](https://img.shields.io/badge/Signed_Commits-100%25-lightgrey.svg) [![Linux build -Status](https://travis-ci.org/hrbrmstr/hrbragg.svg?branch=master)](https://travis-ci.org/hrbrmstr/hrbragg) +Status](https://travis-ci.org/hrbrmstr/hrbragg.svg?branch=master)](https://travis-ci.org/hrbrmstr/hrbragg) +[![Coverage +Status](https://codecov.io/gh/hrbrmstr/hrbragg/branch/master/graph/badge.svg)](https://codecov.io/gh/hrbrmstr/hrbragg) ![Minimal R Version](https://img.shields.io/badge/R%3E%3D-3.6.0-blue.svg) ![License](https://img.shields.io/badge/License-MIT-blue.svg) diff --git a/man/theme_gs.Rd b/man/theme_gs.Rd index ddd7791..79a006f 100644 --- a/man/theme_gs.Rd +++ b/man/theme_gs.Rd @@ -15,7 +15,7 @@ theme_gs( strip_text_size = 12, strip_placement = "outer", caption_size = 10, - caption_margin = 10, + caption_margin = 12, axis_text_size = base_size, axis_title_size = 10, axis_title_just = "rt", diff --git a/man/theme_inter.Rd b/man/theme_inter.Rd index fe7fd6b..2bd6dfc 100644 --- a/man/theme_inter.Rd +++ b/man/theme_inter.Rd @@ -15,7 +15,7 @@ theme_inter( strip_text_size = 12, strip_placement = "outer", caption_size = 9, - caption_margin = 8, + caption_margin = 11, axis_text_size = base_size, axis_title_size = 9, axis_title_just = "rt", diff --git a/man/theme_rc.Rd b/man/theme_rc.Rd index 44fd745..84a5f54 100644 --- a/man/theme_rc.Rd +++ b/man/theme_rc.Rd @@ -15,7 +15,7 @@ theme_rc( strip_text_size = 12, strip_placement = "outer", caption_size = 9, - caption_margin = 10, + caption_margin = 12, axis_text_size = base_size, axis_title_size = 9, axis_title_just = "rt",