lepennec / ggwordcloud

A word cloud geom for ggplot2
https://lepennec.github.io/ggwordcloud/
GNU General Public License v3.0
172 stars 8 forks source link

How to add text annotations to word cloud geom? #23

Open janstrauss1 opened 2 weeks ago

janstrauss1 commented 2 weeks ago

Hi @lepennec,

many thanks again for this great package!

I'd like to use ggwordcloud to plot a word cloud with a custom shape which I'd now like to annotate with custom text (e. g. using geom_textbox or annotate) as done in this blog post.

However, I'm currently not clear how the word cloud geom is placed in the coordinate system and how to properly add the text annotations at specific positions?

Many thanks in advance for your help!

lepennec commented 2 weeks ago

Dear Jan, by default, everything is organized around (.5,5) so that something similar to

set.seed(42)
ggplot(love_words_small, aes(label = word, size = speakers)) +
  geom_text_wordcloud() +
  scale_size_area(max_size = 30) +
  annotate(geom="label", x=.5, y=.5, label="Test", size=8, fill="red") +
  theme_void()

may work.