我創建了一個簡單的wordcloud:如何在grob中放置wordcloud?
require(wordcloud)
words <- c('affectionate', 'ambitious', 'anxious', 'articulate', 'artistic', 'caring', 'contented', 'creative', 'cynical', 'daring', 'dependable', 'easygoing', 'energetic', 'funny', 'generous', 'genuine', 'goodlistener', 'goodtalker', 'happy', 'hardworking', 'humerous', 'impulsive', 'intelligent', 'kind', 'loyal', 'modest', 'optimistic', 'outgoing', 'outrageous', 'passionate', 'perceptive', 'physicallyfit', 'quiet', 'rational', 'respectful', 'romantic', 'shy', 'spiritual', 'spontaneous', 'sweet', 'thoughtful', 'warm')
freqs <- c(134, 53, 0, 5, 0, 247, 0, 78, 0, 0, 134, 178, 79, 344, 63, 65, 257, 0, 109, 113, 0, 0, 107, 51, 199, 24, 67, 232, 0, 109, 24, 28, 29, 2, 105, 70, 0, 35, 64, 156, 66, 45)
wordcloud(words, freqs)
我想放入「GROB」,這樣我可以在gridExtra
包使用grid.arrange()
其他幾個情節安排吧:
require(ggplot2)
p1 <- qplot(1:10, rnorm(10), colour = runif(10))
require(gridExtra)
grid.arrange(p1, my.wordcloud)
我明白我的wordcloud必須是一個「grob」來做到這一點,但我不明白如何做到這一點。我嘗試使用gridExtra
包中的grob()
函數,但這不起作用。建議?
也許這是有用的:http://stackoverflow.com/questions/14124373/combine-base-and-ggplot-graphics-in-r-figure-window/14125768#14125768 – 2013-03-23 06:44:13
wordcloud的繪圖方法使用base圖形,而不是網格圖形(因此沒有grob可以封裝圖形,或者它必須從頭開始編寫)。你最好的選擇是遵循gridBase包的例子。 – baptiste 2013-03-23 07:51:58
相關:http:// stackoverflow。com/questions/11253765/geom-wordcloud-is-this-a-pipe-dream – Spacedman 2013-03-23 19:25:10