配置 ReporteRs 以获得灰度点阵图

configure ReporteRs to get grayscale lattice plots

有没有一种方便的方法来使用 ReportRs 获得 灰度 网格图? trellis.device(color=FALSE) 这里好像不行

library(ReporteRs)
library(lattice)

trellis.device(color=FALSE) # set grayscale

p <- xyplot(decrease ~ treatment, OrchardSprays, groups = rowpos,
            auto.key =list(space = "right"))

print(p) # ok, grayscale

doc = pptx("Test")
doc = addSlide(doc, "Title and Content")
doc = addPlot(doc, fun = print, x = p)  # not ok, colored
writeDoc(doc, "test.pptx")

这里

而不是

使用trellis.par.set就可以了。见下文:

library(ReporteRs)
library(lattice)

p <- xyplot(decrease ~ treatment, OrchardSprays, groups = rowpos,
            auto.key =list(space = "right"))

ltheme <- standard.theme(color = FALSE) 

doc = pptx("Test")
doc = addSlide(doc, "Title and Content")
doc = addPlot(doc, fun = {
  trellis.par.set(ltheme)
  print(p)
}) 
writeDoc(doc, "test.pptx")