Closed pcollender closed 3 years ago
Hey there,
Thanks for letting me know! I can indeed reproduce this error and I agree that it shouldn't happen. I'll fix it here on github when I can find some time to spend on this problem.
Best wishes
In a twist of unexpected events, I creepily felt that I have diagnosed this issue before and it turns out I have: https://github.com/tidyverse/ggplot2/issues/4050. This is not (necessarily) an issue with ggh4x, but also occurs in ggplot2, see the following example:
library(ggplot2)
df = data.frame(x = rnorm(100), y = rnorm(100),
fac1 = factor(sample(4,100, replace = T)),
fac2 = factor(sample(4,100,replace = T)))
ggplot(df, aes(x=x,y=y)) + geom_point() +
facet_grid(.~fac1+fac2) +
theme(strip.text = element_blank())
#> Error in gtable_add_grob(panel_table, strips$x$top, 2, panel_pos_col$l, : Not all inputs have either length 1 or same length same as 'grobs'
Created on 2021-03-19 by the reprex package (v0.3.0)
I'm afraid I can't fix this on the ggh4x side, this should probably get fixed in ggplot2.
I see. Thanks for digging!
Small update: I helped fixing it in ggplot2 dev version but ggh4x has extra code that also throws an error, so I'd need to dig a bit deeper.
This should now work without errors with the dev version of ggh4x. I'll be closing this now.
Excellent! It works now. Thanks so much for digging into this!
Hi there, thanks for coding this very useful extension to ggplot!
I think I found a bug that occurs when panel text is set to element_blank(). Context: I'm trying to apply the ggh4x package to have nested facets for a multi-outcome figure, which I'm arranging using the gridExtra package, trying to only keep facet labels on the leftmost layer but using
facet_nested()
in each strip to maintain formatting. The error can be reproduced with the following code:`df = data.frame(x = rnorm(100), y = rnorm(100), fac1 = factor(sample(4,100, replace = T)), fac2 = factor(sample(4,100,replace = T)))
this works
ggplot(df, aes(x=x,y=y)) + geom_point() +
facet_nested(.~fac1) + theme(strip.text = element_blank())
this works
ggplot(df, aes(x=x,y=y)) + geom_point() +
facet_nested(.~fac1+fac2)
this doesn't work
ggplot(df, aes(x=x,y=y)) + geom_point() + facet_nested(.~fac1+fac2) + theme(strip.text = element_blank()) `