该wordcloud()
函数填充整个绘图。这意味着您需要在绘图之前在图形设备上为标题预留空间。
由于wordcloud
使用基本图形,因此您可以使用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")
这会产生: