I just used ggplot2 earlier and all my plots are appearing without the grey default background. I am not sure why its doing that because it was working two weeks ago and I have not touched R since then. Not sure if its a bug in R or on my part.
library(ggplot2)
library(gridExtra)
library(cowplot)
p1=ggplot(health,aes(Smoker,Pulse))+geom_boxplot(aes(fill=factor(Smoker))) +geom_jitter()
p1
Before I use to get the background with the grey tiles and this what I am getting above. Any help would be great thanks.
答案 0 :(得分:12)
Loading cowplot
changes the default layout of ggplot2
. Check out the cowplot
introduction:
I prefer a clean and sparse layout for publication. I also prefer the approach of building a graph by adding elements rather than taking them away. Therefore, the default design of cowplot has no grid at all. It looks similar to ggplot2’s theme_classic(), but there are a few important but subtle differences, mostly with respect to font sizes.
PS: adding theme_grey()
to your plot should return it to the ggplot2
default