How to make Sentiment Wordcloud where X-axis is Sentiment Score?

Viewed 27

I have the following dataframe of words, their sentiment scores (based off AFINN lexicon) and their occurrences in my text.

gradientCloud <- data.frame(word = c("help", "faith", "love", "no", "hope", "discourage", "hard", "heavenly"),
                            value = c(2, 1, 3, -1, 2, -2, -1, 4),
                            n = c(2150, 1571, 1561, 704, 646, 273, 260, 596))

I would like to make a visualization similar to a wordcloud, but instead of words being randomly placed within a cloud, I'd like there to be an X axis from -5 to 5 and the words be placed on the graph according to their sentiment.

I was able to generate this cloud, but since the different words with different sentiments are mixed together I can only rely on color to help distinguish what is a positive word and what is negative.

library(ggplot2)
library(ggwordcloud)

ggplot(gradientCloud,aes(label = word, size = n, color = value)) +
  geom_text_wordcloud()+
  theme_minimal() +
  scale_color_gradient(low = "darkred", high = "lightblue")

Wordcloud attempt

Ideally "heavenly" would stay off to the right side, but "no" would be on the far left.

0 Answers
Related