From 36c222c32fd0bfc0d7f6e46be7649a218c6b5c9d Mon Sep 17 00:00:00 2001 From: Teun van den Brand <49372158+teunbrand@users.noreply.github.com> Date: Fri, 14 Jul 2023 22:01:04 +0200 Subject: [PATCH] Fix #89 --- NEWS.md | 3 +++ R/facet_nested.R | 8 +++++--- R/themes.R | 2 +- 3 files changed, 9 insertions(+), 4 deletions(-) diff --git a/NEWS.md b/NEWS.md index a34006b..0ebeaff 100644 --- a/NEWS.md +++ b/NEWS.md @@ -1,5 +1,8 @@ # ggh4x (development version) +* Swapped inheritance of `facet_nested(nest_line)`: it is now a line element + that inherits from blank elements, and the theme default is a blank element. + This makes it more responsive to the theme setting (#89). * Anticipated compatability with future ggplot2 > 3.4.2. * `force_panelsizes()` gains a `total_width` and `total_height` argument to set the size of the total panel area. diff --git a/R/facet_nested.R b/R/facet_nested.R index 0fe32eb..0860b44 100644 --- a/R/facet_nested.R +++ b/R/facet_nested.R @@ -66,7 +66,7 @@ facet_nested <- function( switch = NULL, drop = TRUE, margins = FALSE, - nest_line = element_blank(), + nest_line = element_line(inherit.blank = TRUE), resect = unit(0, "mm"), strip = strip_nested(), bleed = NULL @@ -234,13 +234,15 @@ FacetNested <- ggproto( add_nest_indicator <- function(panels, params, theme) { # Convert nest line to proper element nest_line <- params$nest_line - if (is.null(nest_line) || isFALSE(nest_line) || - inherits(nest_line, "element_blank")) { + if (is.null(nest_line) || isFALSE(nest_line)) { return(panels) } nest_line <- inherit_element( nest_line, calc_element("ggh4x.facet.nestline", theme) ) + if (inherits(nest_line, "element_blank")) { + return(panels) + } # Find strips layout <- panels$layout diff --git a/R/themes.R b/R/themes.R index be1056c..4c230eb 100644 --- a/R/themes.R +++ b/R/themes.R @@ -26,7 +26,7 @@ #' used in the [`guide_axis_logticks()`] function. Defaults to `rel(1/3)`. ggh4x_theme_elements <- function() { register_theme_elements( - ggh4x.facet.nestline = element_line(), + ggh4x.facet.nestline = element_blank(), ggh4x.axis.nestline = element_line(), ggh4x.axis.nestline.x = element_line(), ggh4x.axis.nestline.y = element_line(),