R语言 | 制作词云图
wordcloud2文档
https://github.com/lchiffon/wordcloud2
安装
install.packages("wordcloud2")
词云图可视化
02-词频统计已经帮我们计算好了小说《三体》的词频结果三体词频统计.xlsx
导入数据
wordfreqs <- readxl::read_excel("output/三体词频统计.xlsx")
wordfreqs
词云图
默认
直接传入wordfreqs数据即可生成词云图
library(wordcloud2)
wordcloud2(wordfreqs)
wordcloud2参数
 
 我们看一下wordcloud2的参数
wordcloud2(data, 
           size = 1, 
           fontFamily = 'Segoe UI', 
           fontWeight = 'bold', 
           color = 'random-dark', 
           backgroundColor = "white", 
           shuffle = TRUE, )
-  
   size 默认1,越大,词越大 
-  
   fontFamily 字体;比如字体“微软雅黑” 
-  
   fontWeight 字体是否加粗,可选参数有normal, bold, 600 
-  
   color 字体颜色;可选参数random-dark、 random-light 
-  
   backgroundColor 任意的颜色单词 
-  
   shuffle 布尔值;词云图的词语位置随机性 
library(wordcloud2)
wordcloud2(wordfreqs, 
           fontFamily = "微软雅黑",
           color="random-light")
wordcloud2(wordfreqs, 
           fontFamily = "微软雅黑",
           color="random-dark")
wordcloud2(wordfreqs, 
           size=2,
           fontFamily = "微软雅黑",
           color="random-dark")
wordcloud2(wordfreqs, 
           size=2,
           fontFamily = "微软雅黑",
           color="random-dark",
           backgroundColor = 'grey')
R语言相关
Python相关
后台回复关键词【R词云图】获取本文代码和数据 
