Closed henda52 closed 7 years ago
The size in wordcloud2 is not responsive. If the size of the word is larger than the space, it would not show in the wordcloud. Instead, you can set size as a smaller number, like 0.5.
I had this problem myself, and I wanted to share my solution. My two data frames had over 1500 words, with about half of them being used only once, and the top words in both data frames having a frequency count of several hundred. When I set the size to 0.3 so that wordcloud2 would display my top words, then the other words were displayed in such a tiny font that they were both unreadable and didn't even fill up my custom figure. I solved this by taking the square root of all of my word frequencies, which evened out the extreme polarity between 1 instance of use and 400 instances of use of words. My word clouds still require me to set the size fairly small, but they now show the top words just fine, the less popular words aren't too tiny, and the size difference between the smallest and largest isn't as extreme.
Beautiful package, thank you, Lchiffon!
The adaptation offered by @aeluro gives very nice results visually. A new (small) issue arises, though: the values shown on mouse-over are both "wrong" (it's the square-root values) and shown with way too many decimals. Although the mouse-over functionality of wordcloud2 is a very nice touch, it's kind of negated in this case. Other than that, the result does indeed look much better with @aeluro's adaptation.
Square root solved my problem entirely and I overcame the "wrong" tooltip with the following bit of JS:
$(document).on("mousemove", '#canvas', function(){ var n = document.getElementById("wcSpan").getAttribute("data-l10n-args").lastIndexOf(':'); var count = document.getElementById("wcSpan").getAttribute("data-l10n-args").substring(n + 1); var freq = count.slice(0, -1); var new_freq = Math.pow(freq, 2); var m = document.getElementById("wcSpan").innerHTML.lastIndexOf(':'); var job = document.getElementById("wcSpan").innerHTML.substr(0, m); document.getElementById("wcSpan").innerHTML = job + ":" + Math.round(new_freq); });
When I use letterCloud, it doesn't display all the high frequency words. The longer words I try to spell in letterCloud, the more words are missing. I notice that it is the same in the vignette https://cran.r-project.org/web/packages/wordcloud2/vignettes/wordcloud.html. The letterCloud for "R" doesn't display "Oil" and "Said" that appears to be the words with highest frequencies (displayed in the wordclouds above). The same for the "WORDCLOUD2" example in the vignette.