teunbrand / ggh4x

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

Text aesthetics in nested facets not working #135

Closed shirewoman2 closed 7 months ago

shirewoman2 commented 7 months ago

I'm attempting to adjust the text appearance in nested facets, and it doesn't seem to be working. Using the graph from the main vignette with the iris dataset, when I add these theme calls to the main graph g:

g + theme(ggh4x.axis.nesttext.x = element_text(color = "dodgerblue4", size = rel(1.5)), ggh4x.facet.nestline = element_line(colour = "dodgerblue4"))

I see a blue line between "Long Leaves" (top row) and "versicolor" and "virginica" (2nd row) but no line between "Short Leaves" (top row) and "setosa" (2nd row). I also don't see any changes to the text: It's still black instead of blue and the size is the same. Here's the graph.

Am I doing something wrong?

Pretty happy to see these ggplot2 hacks, so thanks for developing this!

teunbrand commented 7 months ago

I see a blue line between "Long Leaves" (top row) and "versicolor" and "virginica" (2nd row) but no line between "Short Leaves" (top row) and "setosa" (2nd row).

Yes that should be correct, there is no nesting to indicate when there is a 1:1 correspondence between inner and outer strips. You can set facet_nested(..., solo_line = TRUE) to draw a line anyway.

I also don't see any changes to the text: It's still black instead of blue and the size is the same.

That is because that theme element controls axis text, not strip text. To tweak the appearance of individual strips (or by layer) you can follow this piece of vignette, which also applies to facet_nested(strip = strip_nested(...)).

thanks for developing this!

Glad to see people find it useful!

shirewoman2 commented 7 months ago

Thank you very, very much for all of this! Everything is working now for me. It's fantastic! I love how much clearer my graphs are now that I can add a title to the facets.