ChazzFingers
ChazzFingers

Reputation: 1

ggwordcloud: huge border/margin around each word

I'm trying to create some wordclouds using ggwordcloud but no matter how I fiddle with the arguments in geom_wordcloud_area() my wordclouds come out looking horrible with each word having a huge margin of white space around it. Every online tutorial has super slick looking examples (i.e. this, and this, and of course) however mine look like this no matter what I do:

My bad looking wordcloud

Code for the above wordcloud (I appreciate that the frequency column/scaling of it seem weird but that's not the issue here - this issue happens with any word/freq pairs I input):

ggplot(word_freq %>% filter(freq > 0.01), aes(label = WORD, size = freq^3)) + 
geom_text_wordcloud(eccentricity = 1) +
scale_size_area(max_size = 10)+
theme_minimal()

Would be incredibly grateful if anyone knows what's going on - this has taken up a ridiculously huge amount of time.

Upvotes: 0

Views: 788

Answers (1)

Marek Fiołka
Marek Fiołka

Reputation: 4949

It all depends on how you prepared your data. Take a look at my example

library(tidyverse)
library(ggwordcloud)

n=100
word_freq = tibble(
  WORD = rep("word", n),
  freq = abs(rnorm(n))*1000
) %>% mutate(freq = ifelse(freq<100,100,freq))

word_freq %>% 
  ggplot(aes(label = WORD, size = freq)) + 
  geom_text_wordcloud(eccentricity = 1) +
  scale_size_area(max_size = 10)+
  theme_minimal()

enter image description here Does it look good enough for you?

Upvotes: 1

Related Questions