Repository navigation
Closed
Description
Hi there,
thanks for this useful package. Since one of the more recent updates (before updating to the current version I used 0.6.2) I'm experiencing some weird issues with the interaction between plot_grid(), theme_set(), and a theme of mine that modifies axis.text.x.
Everything works great as long as I don't use theme_set().
Works as expected:
library("ggplot2")
library("cowplot")
df <- data.frame(
gp = factor(rep(letters[1:3], each = 10)),
y = rnorm(30)
)
test <- ggplot(df, aes(gp, y)) +
geom_point() +
theme_classic() +
theme(axis.text.x = element_text())
plot_grid(test)
Throws an error:
theme_set(theme_classic() + theme(axis.text.x = element_text()))
test2 <- ggplot(df, aes(gp, y)) +
geom_point()
plot_grid(test2)
Error in element_grob.element_text(el, ...) :
Text element requires non-NULL value for 'angle'.
If I set angle I get another error:
theme_set(theme_classic() + theme(axis.text.x = element_text(angle = 0)))
plot_grid(test2)
Error in if (debug) { : Argument has length 0
Now, if I set debug = FALSE it finally works, but I get some weird numbering on the bottom margin.
This is my session info:
Session info ---------------------------------------------------------------------------------------------------------------------------
setting value
version R version 3.3.2 (2016-10-31)
system x86_64, linux-gnu
ui RStudio (1.0.136)
language de_DE
collate de_DE.UTF-8
tz <NA>
date 2017-02-24
Packages -------------------------------------------------------------------------------------------------------------------------------
package * version date source
assertthat 0.1 2013-12-06 CRAN (R 3.3.0)
colorspace 1.2-6 2015-03-11 CRAN (R 3.3.0)
cowplot * 0.7.0 2017-02-24 Github (wilkelab/cowplot@78336ac)
devtools 1.12.0 2016-06-24 CRAN (R 3.3.1)
digest 0.6.11 2017-01-03 CRAN (R 3.3.2)
ggplot2 * 2.2.1 2016-12-30 CRAN (R 3.3.2)
gtable 0.2.0 2016-02-26 CRAN (R 3.3.0)
labeling 0.3 2014-08-23 CRAN (R 3.3.0)
lazyeval 0.2.0 2016-06-12 CRAN (R 3.3.0)
memoise 1.0.0 2016-01-29 CRAN (R 3.3.0)
munsell 0.4.3 2016-02-13 CRAN (R 3.3.0)
plyr 1.8.4 2016-06-08 CRAN (R 3.3.0)
Rcpp 0.12.9.3 2017-02-24 Github (RcppCore/Rcpp@8bf15c0)
scales 0.4.1 2016-11-09 CRAN (R 3.3.2)
tibble 1.2 2016-08-26 CRAN (R 3.3.1)
withr 1.0.2 2016-06-20 CRAN (R 3.3.1)
Metadata
Metadata
Assignees
Labels
No labels

Activity
clauswilke commentedon Feb 24, 2017
This is a bug in
ggplot2, specifically intheme_void(). Please report there. Here is how to show it's aggplot2bug:crsh commentedon Feb 24, 2017
Thanks, will do.
clauswilke commentedon Feb 24, 2017
Work-around:
In
ggplot2:In `cowplot:
I don't want to make this change in the
cowplotpackage, becausetheme_void()should work properly and I shouldn't have to work around its bugs.FMKerckhof commentedon May 4, 2017
Hi Claus, I tried the workaround with
assignInNamespace(I take it that all changed theme elements should be set to NULL) but keep ending up with the sameError in if (debug) { : Argument has length 0error. The only thing that does help is detaching and reloading the cowplot package right before the call toplot_grid. Do you think this is the same bug in theme_void() causing this behavior? Am I missing something in how your suggested workaround operates?My
devtools::session_info()is the following:clauswilke commentedon May 4, 2017
Please post an example of code that causes this error for you. Thanks!
Fix issue #60 and related issues.
clauswilke commentedon Jul 28, 2017
Since this issue is still not resolved in the ggplot2 code base, I have decided to reimplement
theme_nothing()so it avoids this problem. So going forward, this will not be a problem anymore.The code is currently on github and will be in the upcoming cowplot 0.8.0.
Fix issue wilkelab#60 and related issues.