Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Lettercloud skips words #16

Closed
henda52 opened this issue Jan 10, 2017 · 4 comments
Closed

Lettercloud skips words #16

henda52 opened this issue Jan 10, 2017 · 4 comments

Comments

@henda52
Copy link

henda52 commented Jan 10, 2017

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.

@Lchiffon
Copy link
Owner

Lchiffon commented Jan 10, 2017

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.

@aeluro
Copy link

aeluro commented Mar 20, 2018

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!

@solarchemist
Copy link

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.

@parrot95
Copy link

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);
});

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants