的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")
這產生:
這是一個不錯的主意,也許我會用這額外的信息添加到之後的PNG。但它不完全是我想要的 - 在wordcloud一代時插入一個標題。 – knb 2013-03-05 15:32:02
@knd我認爲你的問題的標題(png)會導致我錯誤。安德里給你正確的答案。這個答案就像情節的註解一樣。 – agstudy 2013-03-05 15:44:51