使用wordcloud
包,我需要將wordclouds調整爲矩形。 wordcloud本身的創建不成問題。我使用的是自定義函數:R-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。然而,似乎所有這些wordclouds的形狀往往是圓形的。然而,在我的規範中,我需要創建矩形的wordclouds。 F.i:
通盤考慮,對於以前的圖像我已經手動調整「通知」 wordcloud。
我開始將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中wordclouds與圓形以外的形狀?
您是否嘗試在'wordcloud'函數調用中設置'fixed.asp = F'? –
看看[wordcloud2](https://cran.r-project.org/web/packages/wordcloud2/vignettes/wordcloud.html)。 – Henrik