amueller / word_cloud

A little word cloud generator in Python
https://amueller.github.io/word_cloud
MIT License
10.09k stars 2.31k forks source link

Word Sizes Not Always the Same for Words with Same Frequencies #285

Open divyansha opened 7 years ago

divyansha commented 7 years ago

I recently passed in a document where each word occurs only once. The resulting word cloud did not have all words of the same size. Are there any possible reasons why this is happening other than a bug (I used the code example provided in the Readme)?

amueller commented 7 years ago

The space-filling algorithm that is used basically tries to place words one after another. This will preserve ranks of words, but not necessarily respect frequencies. If there is not enough space to place a word the font will be made smaller. You can guarantee that all words will get the same size if you set the maximum font size small enough so that all words can be drawn without decreasing font-size.

amueller commented 6 years ago

Maybe it would be good to have an FAQ with this in it.

un-lock-me commented 5 years ago

I have the same problem. It seems when the frequency of the words in a document is the same this happen. this is the problem I posted in stackoverflow: https://stackoverflow.com/questions/54566343/word-cloud-does-not-show-the-frequency-of-the-words-correctly?noredirect=1#comment95964240_54566343 any update how can I fix it?

Thanks.

amueller commented 5 years ago

As I said above: decrease the maximum font size.

un-lock-me commented 5 years ago

Well, I figured out I need to set both maximum size and min size to make sure word cloud showing the frequencies of the words correctly. before I had not set any size and it was the default. Although the number of words is not too much to face a problem in case of the space, the default font size shows an incorrect result. Thanks anyway I set the max and min accordingly and now it works well.

tirth78 commented 2 years ago

I would like to work on this issue. I am a Masters student in BITS Pilani. It would be really helpful if I could get some kind of approval from the owner/author.

amueller commented 1 year ago

@tirth78 feel free to start on any of these issues.