R - 词云调整为矩形
R - wordcloud adjusted in a rectangular shape
使用wordcloud
包,我需要将wordclouds调整为矩形。 wordcloud 本身的创建不是问题。我正在使用自定义函数:
createCorpus <- function (name, name2, output) {
# Here comes all the processing for generating a corpus
# irrelevant for this question
# Create wordcloud and save the image in png format
png(output, width=7.5, height=5, units="cm", res=140, bg = "white")
wordcloud(ordered.colors=TRUE,
words = topfeatures$keyName,
freq = topfeatures$value.x,
scale=c(1,.5),
min.freq=2,
max.words=10,
random.order=T,
rot.per=.0)
dev.off()
}
运行 函数 (f.i.:)
createCorpus(markenmonitoring$Content, "termsmm", "wcMM.png")
结束生成带有 wordcloud 的 png。然而,似乎所有这些词云的形状都倾向于圆形。然而,在我的规范中,我需要创建矩形的词云。 F.i:
请注意,对于上一张图片,我手动调整了 "circular" 文字云的大小。
我开始将 rot.per
参数更改为 .0,从而防止垂直输出单词。但是,它似乎没有帮助。只要我限制我的输出高度(f.i.: png(output, width=7.5, height=2.5, units="cm", res=140, bg = "white")
),我就会得到以下错误:
Error in plot.new() : figure margins too large
问题:我可以在 R 中制作非圆形的词云吗?
根据我最近几个小时的个人经验,这是不可能的。
我读过 wordcloud package description 并且没有任何参数可以设置为使 wordcloud 水平。
使用wordcloud
包,我需要将wordclouds调整为矩形。 wordcloud 本身的创建不是问题。我正在使用自定义函数:
createCorpus <- function (name, name2, output) {
# Here comes all the processing for generating a corpus
# irrelevant for this question
# Create wordcloud and save the image in png format
png(output, width=7.5, height=5, units="cm", res=140, bg = "white")
wordcloud(ordered.colors=TRUE,
words = topfeatures$keyName,
freq = topfeatures$value.x,
scale=c(1,.5),
min.freq=2,
max.words=10,
random.order=T,
rot.per=.0)
dev.off()
}
运行 函数 (f.i.:)
createCorpus(markenmonitoring$Content, "termsmm", "wcMM.png")
结束生成带有 wordcloud 的 png。然而,似乎所有这些词云的形状都倾向于圆形。然而,在我的规范中,我需要创建矩形的词云。 F.i:
请注意,对于上一张图片,我手动调整了 "circular" 文字云的大小。
我开始将 rot.per
参数更改为 .0,从而防止垂直输出单词。但是,它似乎没有帮助。只要我限制我的输出高度(f.i.: png(output, width=7.5, height=2.5, units="cm", res=140, bg = "white")
),我就会得到以下错误:
Error in plot.new() : figure margins too large
问题:我可以在 R 中制作非圆形的词云吗?
根据我最近几个小时的个人经验,这是不可能的。
我读过 wordcloud package description 并且没有任何参数可以设置为使 wordcloud 水平。