Background
I would like to change the theme used by ggplot, but it's hard for me to understand the documentation and examples of theme_update() .
I use align_plots() to place the rectangle above the density graph, but I did not find that none of these codes caused an error and was left with a minimal example. I suspect the error is caused by using theme_blank() , but I'm not sure why this is happening or how I can fix it.
So here I provide a minimal reproducible example of the error I get:
library(ggExtra) align.plots(qplot(1))
But it breaks after updating the topic:
newtheme <- theme_update(axis.text.y = theme_blank(), axis.line = theme_blank(), axis.title.x = theme_blank(), axis.title.y = theme_blank(), axis.ticks.x = theme_blank(), panel.grid.major = theme_blank(), panel.grid.minor = theme_blank(), panel.border = theme_blank(), axis.color.y = 'white') align.plots(qplot(1))
This gives an error:
Error in UseMethod("validGrob") : no applicable method for 'validGrob' applied to an object of class "NULL" In addition: Warning message: In editThisGrob(grob, specs) : Slot 'vp' not found
Questions:
Note:
I get the same error with a solution based on Hadley's suggestion for another question.
opt <- opts(...) align.plots(qplot(1) + opt)
where ... is the contents of theme_update() above
r ggplot2
David LeBauer
source share