相关疑难解决方法(0)

如何更改ggplot2中的默认主题?

背景

我想改变ggplot使用的主题,但我很难理解theme_update()文档和示例.

align_plots()用来在密度图上放置一个箱线图,但我发现没有任何代码导致错误,并留下了最小的例子.我怀疑错误是由使用引起的theme_blank(),但我不确定它为什么会发生或我如何解决它.

所以,在这里,我提供了一个最小的可重现的错误示例:

library(ggExtra)
align.plots(qplot(1))
Run Code Online (Sandbox Code Playgroud)

但是在我更新主题后它会中断:

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))
Run Code Online (Sandbox Code Playgroud)

这给出了错误:

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
Run Code Online (Sandbox Code Playgroud)

问题:

  1. 是什么导致这个错误?

  2. 我在哪里可以获得有关使用的更多信息?theme_update()?我得到这个远在ggplot文件,并不能找到的答案ggplot网站,但我得到的最接近是polishing.r …

r ggplot2

8
推荐指数
2
解决办法
8620
查看次数

标签 统计

ggplot2 ×1

r ×1