Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

A word cloud geom for ggplot2

License

NotificationsYou must be signed in to change notification settings

lepennec/ggwordcloud

Repository files navigation

CRAN status

ggwordcloud provides a word cloud text geom forggplot2. Theplacement algorithm implemented in C++ is an hybrid between the one ofwordcloud and the one ofwordcloud2.js. The cloud can grow accordingto a shape and stay within a mask. The size aesthetic is used either tocontrol the font size or the printed area of the words.ggwordcloudalso supports arbitrary text rotation. The faceting scheme ofggplot2can also be used. Two functions meant to be the equivalent ofwordcloud andwordcloud2 are proposed. Last but not least you canusegridtext markdown/html syntax in the labels.

Installation

You can install the released version of ggwordcloud fromCRAN with:

install.packages("ggwordcloud")

or the development version from the github repository

devtools::install_github("lepennec/ggwordcloud")

Please check the latest development version before submitting an issue.

Some word clouds

Because sometimes, pictures are better than a thousand words…

library(ggwordcloud)#> Loading required package: ggplot2data("love_words_small")set.seed(42)ggplot(love_words_small, aes(label=word,size=speakers))+  geom_text_wordcloud()+  scale_size_area(max_size=40)+  theme_minimal()

data("love_words")set.seed(42)ggplot(love_words,  aes(label=word,size=speakers,color=speakers  ))+  geom_text_wordcloud_area(aes(angle=45* sample(-2:2, nrow(love_words),replace=TRUE,prob= c(1,1,4,1,1)  )),mask=png::readPNG(system.file("extdata/hearth.png",package="ggwordcloud",mustWork=TRUE  )),rm_outside=TRUE  )+  scale_size_area(max_size=40)+  theme_minimal()+  scale_color_gradient(low="darkred",high="red")#> Some words could not fit on page. They have been removed.

library(dplyr,quietly=TRUE,warn.conflicts=FALSE)library(tidyr,quietly=TRUE)set.seed(42)ggplot(love_words_small %>%    gather(key="type",value="speakers",-lang,-word) %>%    arrange(desc(speakers)),  aes(label=word,size=speakers))+  geom_text_wordcloud_area()+  scale_size_area(max_size=40)+  theme_minimal()+  facet_wrap(~type)

set.seed(42)ggplot(love_words_small, aes(label=word,size=speakers,label_content= sprintf("%s<span style='font-size:7.5pt'>(%g)</span>",word,speakers)))+  geom_text_wordcloud_area()+  scale_size_area(max_size=40)+  theme_minimal()

More examples are available in the vignette.

About

A word cloud geom for ggplot2

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Contributors2

  •  
  •  

[8]ページ先頭

©2009-2026 Movatter.jp