knb*_*knb 11 graphics r word-cloud tm
我有一些工作R代码,从术语 - 文档矩阵生成标签云.
现在我想从许多文档中创建一大堆标记云,并在以后可视化地检查它们.为了知道标签 - 云图片属于哪个文档/语料库,我想为生成的图形添加标题.我怎么做?
也许这很明显,但我仍然是R图形的初学者.
我自己的语料库太大了,无法在此列出,但是这个SO问题的代码(结合代码形成SO用户Andrie的接受答案)可以使用: wordcloud中的空格 我想添加自定义标题和一些更自定义的文本像照片这样
And*_*rie 17
该wordcloud()
功能填充整个图.这意味着在绘图之前,您需要在图形设备上为标题预留空间.
由于wordcloud
化妆用的基础grapics的,你可以做这一点par(mfrow=...)
还是layout()
.然后用text()
.创建情节标题.
我举例说明layout()
,调整示例?wordcloud
:
library(tm)
library(wordcloud)
x <- "Many years ago the great British explorer George Mallory, who
was to die on Mount Everest, was asked why did he want to climb
it. He said, \"Because it is there.\"
Well, space is there, and we're going to climb it, and the
moon and the planets are there, and new hopes for knowledge
and peace are there. And, therefore, as we set sail we ask
God's blessing on the most hazardous and dangerous and greatest
adventure on which man has ever embarked."
layout(matrix(c(1, 2), nrow=2), heights=c(1, 4))
par(mar=rep(0, 4))
plot.new()
text(x=0.5, y=0.5, "Title of my first plot")
wordcloud(x, main="Title")
Run Code Online (Sandbox Code Playgroud)
这会产生: