簡體   English   中英

如何使用 wordcloud2 的自定義形狀在 R 中制作 wordcloud?

[英]How to make a wordcloud in R using a custom shape with wordcloud2?

我想在 R 中創建一個 wordcloud,其中的單詞在圖片的形狀內。 一個常見的例子是使用 Twitter 鳥形狀,如具有特定形狀的 Wordcloud所示。

雖然我遵循了多個教程,但我的代碼總是導致一張空表。 沒有形狀的標准可視化效果很好。

library(wordcloud2)
library(RColorBrewer)

wordcloud2(demoFreq, size = 0.7, shape = 'star') # -> this works fine

#put picture in current working directory
getwd() #get current working directory
wordcloud2(demoFreq, figPath="heart.png", size = 1.5, color = "skyblue", backgroundColor="black") # -> this does not show anything

我使用的心形圖像鏈接 worldcloud2故障排除時從 github master repo 安裝了worldcloud2 ,不確定這是否有幫助。 在我在 worldcloud2 函數中添加size=1之前,我沒有任何渲染。 我也將圖片另存為.jpg

library(wordcloud2)
library(RColorBrewer)
#library(devtools)
#install_github("lchiffon/wordcloud2")


wordcloud2(demoFreq,size = 1,figPath = "heart.jpg") 

在此處輸入圖片說明

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM