teunbrand / ggh4x

ggplot extension: options for tailored facets, multiple colourscales and miscellaneous
https://teunbrand.github.io/ggh4x/
Other
533 stars 32 forks source link

[bug?] nestline is element_blank by default #89

Closed pank closed 12 months ago

pank commented 1 year ago

Hi,

Perhaps I am misunderstanding the docs, but wouldn't it make more sense if the nest_line argument of facet_nested would inherit directly from the theme instead of being element_blank (formals(facet_nested)$nest_line => element_blank())? Then the default theme value could be set to element_blank().

In particular, I would have thought that g1 and g2 would be identical in the below example:

library(ggh4x)
library(patchwork)
d <- data.frame(x = 1:10,
                y = 1:10,
                outer = rep(LETTERS[1:3],  each=3,  length.out = 10),
                inner = rep(letters[4:5],  each=7, length.out = 10))

g1 <- ggplot(d, aes(x, y)) + geom_point() +
    facet_nested(outer+inner ~ ., nest_line = element_line())
g2 <- ggplot(d, aes(x, y)) + geom_point() +
    facet_nested(outer+inner ~ .) +
    theme(ggh4x.facet.nestline = element_line())
g1 + g2

Uploading images isn't working for me atm, but I would have thought both g1 and g2 would have nestlines, but they are only shown in g1.

teunbrand commented 1 year ago

I agree that this is awkward and could be improved, but I don't know when I'll have time to get around to this though.

teunbrand commented 12 months ago

This should now work as intended in the dev version:

library(ggh4x)
#> Loading required package: ggplot2
#> Warning: package 'ggplot2' was built under R version 4.1.3
library(patchwork)
d <- data.frame(x = 1:10,
                y = 1:10,
                outer = rep(LETTERS[1:3],  each=3,  length.out = 10),
                inner = rep(letters[4:5],  each=7, length.out = 10))

g1 <- ggplot(d, aes(x, y)) + geom_point() +
  facet_nested(outer+inner ~ ., nest_line = element_line())
g2 <- ggplot(d, aes(x, y)) + geom_point() +
  facet_nested(outer+inner ~ .) +
  theme(ggh4x.facet.nestline = element_line())
g1 + g2

Created on 2023-07-14 by the reprex package (v2.0.1)