The wordcloud()
函数填充了整个绘图。这意味着您需要在绘图之前在图形设备上为标题预留空间。
Since wordcloud
利用基本图形,您可以使用以下任一方法来执行此操作par(mfrow=...)
or 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")
这会生成: