Closed pank closed 3 years ago
Hello there,
I've seen more requests like this, in private email and on stackoverflow. This makes me think that it probably is a more widely requested feature.
It can probably be implemented, but I'd have to define separate theme elements for every layer I'd support. E.g. strip.text.x.bottom.level0
, strip.text.x.bottom.level1
, strip.background.x.bottom.level0
, strip.background.x.bottom.level1
etc., and this is just for two levels for strips on one side of the plot. You can probably see this become cumbersome pretty quickly.
The alternative I had in mind, is to implement guide_strips()
in a similar fashion as ggplot2 has guide_axis()
, guide_legend()
and guide_colourbar()
. These can then have variants like guide_strips_nested()
and the like, and can probably be made to facilitate different styles per layer.
In any case, I don't have the time to implement something like this in the near future, but I might do this once I have some extra time.
Best, Teun
Alright I've merged some strip related changes into the main branch. The following should now work with the github version:
library(ggplot2)
library(ggh4x)
df <- data.frame(outer = c("A","B", "B", "C", "C", "C"),
inner = paste("Lorem ipsum dolor sit amet", 1:6),
x=1, y =1)
theme_set(theme_get() + theme(strip.text.y.right = element_text(angle = 0)))
ggplot(df, aes(x,y)) +
geom_point() +
facet_nested(
outer + inner ~ .,
scales = "free_y",
space = "free_y",
strip = strip_nested(
background_y = list(NULL, element_rect(fill = "green")),
by_layer_y = TRUE
)
)
Created on 2021-06-29 by the reprex package (v1.0.0)
If you find any bugs, please let me know :)
Am wondering if it is possible to apply an alternating theme to only one layer of nested strips?
like this:
No there isn't, you'd have to set this manually I'm afraid.
facet_nested
is really great. I use for having nested "boxes" on my y-axis.It would be very useful if different theme elements could be used for different levels of the nested facet so that inner facets could have a different background, say. It's not too hard to do this afterward with
grid
, but it would be much nicer to usetheme
.Would something like that be feasible? I am also happy to try to write a patch.
Example: