I want to set the angle of facet labels for vertical axis and I noticed that I have to use set strip.text.y in the theme specifically as it does not seem to inherit if I set the angle at the level of its parent, strip.text, even if complete=TRUE.
Why is that? (Perhaps I'm using an incomplete theme without realizing it?) Using ggplot2 v3.3.3.
The following attempts to set angle=45 doesn't change the default angle rendering.
(p <- ggplot(iris, aes(x=Petal.Length)) geom_histogram() facet_grid(rows = vars(Species)))
p theme(strip.text = element_text(angle=45))
p theme(strip.text = element_text(angle=45), complete=TRUE) #Results in heavier font.

Why didn't complete=TRUE trigger inheritance?
Had to be specific:
p theme(strip.text.y = element_text(angle=45)) # Works!
I read the section titled "Complete vs Incomplete (themes)" in the vignette below but that wasn't clear on this issue.
https://cran.r-project.org/web/packages/ggplot2/vignettes/extending-ggplot2.html
CodePudding user response:
There is a hierarchy for theme elements:
strip.textinherits fromtextstrip.text.yinherits fromstrip.textstrip.text.y.left(and right) inherits fromstrip.text.y.
'Inheritance' in the theme's case means that a child's properties get filled in by the parent's properties, when this property is missing in the child.
If you evaluate theme_get()$strip.text.y with the default theme, you'll see that angle is -90: not missing. So whenever you set something in the parent strip.text, the strip.text.y's angle overrules the parents angle. I think Kara Woo discussed this behaviour in this talk.
As a sidenote, I don't think you ever need to specify complete for normal plotting purposes. It might only be a useful argument for building new themes for a package or something.

