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

问题描述

我想在R中创建一个单词云,其中单词在图片的形状内。一个常见的示例是使用Twitter鸟形,如Wordcloud with a specific shape所示。

尽管我遵循了多个教程,但是我的代码始终会导致空白。没有形状的标准可视化效果很好。

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

解决方法

Heart image link i used。我在进行故障排除时从github主存储库安装了worldcloud2,不确定是否有帮助。在我将size=1添加到worldcloud2函数之前,没有任何东西可以呈现给我。我也将图片另存为 .jpg

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


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

enter image description here

相关问答

错误1:Request method ‘DELETE‘ not supported 错误还原:...
错误1:启动docker镜像时报错:Error response from daemon:...
错误1:private field ‘xxx‘ is never assigned 按Alt...
报错如下,通过源不能下载,最后警告pip需升级版本 Requirem...