1

我正在 R 中测试 Waffle 包(https://github.com/hrbrmstr/waffle),我在 Microsoft Windows 10 下使用 R 版本 3.2.2(32 位),当我想绘制一个来自 R 脚本的华夫饼图。

如果我直接从 R 控制台绘制华夫饼图,则绘制此图表没有问题,仅当我从 R 脚本加载图表且未显示时才会出现此问题。

这是我的 R 脚本上的代码:

library(waffle)
mm.counts <- c(12, 6, 8, 10, 6, 7)
names(mm.counts) <- c("blue", "brown", "green", "orange", "red", "yellow")
waffle(mm.counts, rows = 7, colors = names(mm.counts), title = "M&M Colors")
4

1 回答 1

0

简单的解决方案是在脚本中明确打印情节

> test.R

library(waffle)
mm.counts <- c(12, 6, 8, 10, 6, 7)
names(mm.counts) <- c("blue", "brown", "green", "orange", "red", "yellow")
wp <- waffle(mm.counts, rows = 7, colors = names(mm.counts), title = "M&M Colors")
print(wp)

然后调用脚本

source("test.R")

瞧:

华夫饼图

于 2018-10-02T20:59:23.160 回答