ggplot2中的图出现,没有灰色背景 [英] Plots in ggplot2 appearing without grey background
问题描述
我刚刚使用了ggplot2,并且所有的地块都没有灰色的默认背景。我不确定为什么它会这样做,因为它在两周前就开始工作了,从那以后我还没有碰过R。不知道它是否存在R或我的错误。
library(ggplot2)
library(gridExtra)
library(cowplot)
p1 = ggplot(health,aes(Smoker,Pulse))+ geom_boxplot(aes(fill = factor(Smoker)))+ geom_jitter()
p1
在我用灰瓦而这正是我得到的。任何帮助将非常感谢。 加载 cowplot
更改 GGPLOT2
。查看 cowplot
介绍:
我更喜欢干净而稀疏的发布版面。我还喜欢通过添加元素来构建图表的方法,而不是将它们带走
。因此,cowplot的默认设计在
都没有网格。它看起来类似于ggplot2的theme_classic(),但是有一个
几个重要但很细微的差异,主要是关于字体
的大小。
PS:将 ggplot2
默认
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.
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
这篇关于ggplot2中的图出现,没有灰色背景的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!