wmf 未使用参数的 ggsave 错误bg = "white"

问题描述

ggplot (3.3.4) 中的 ggsave 生成​​此错误

Grdevices::win.Metafile(...) 中的错误:未使用的参数 (bg = "white")

但是,我可以使用 RStudio 以交互方式导出绘图 |绘图菜单

可重现的例子:

library(tidyverse)
e <- ggplot(mpg,aes(cty,hwy))
e + geom_point()
ggsave("test.wmf")
ggsave("test.emf")

保存 8.98 x 5.98 的图像

Grdevices::win.Metafile(...) 中的错误:未使用的参数 (bg = "white")

ggsave("test.emf")

保存 8.98 x 5.98 的图像

Grdevices::win.Metafile(...) 中的错误:未使用的参数 (bg = "white")

一些进一步的故障排除表明问题出在 ggsave 上,因为此代码工作正常:

library(tidyverse)
e <- ggplot(mpg,hwy))
e <- e + geom_point()
win.Metafile("test.wmf")
print(e)
dev.off()

解决方法

ggplot2 3.3.4 中的此错误已在 ggplot2 3.3.5 中解决。