Closed abubelinha closed 1 year ago
If you want identical output, you can change scale
, which should return identical results. If you run with different sizes, the results will be different because the font size calculations are mostly in absolute terms, not relative terms. The max_font_size
is the main factor determining the look of the image, and there's a heuristic that tries to adjust it, but depending on the value of relative_scaling
, font_step
is used, which is also done in absolute terms.
In other words, I made no attempt to make the layout stable wrt changing the image size. If you simply want different sized outputs, use scale
. It might be possible to get consistent output by changing all of the variables relating to font size in a consistent way, but I'm not sure what the purpose of that would be (as by definition, you'd get the same result as with using scale if you succeed).
Controlling random_state
should give you consistent results with the same sizes, but if you change the input to the algorithm, the output changes accordingly.
Thanks for explanations. I'll try
Description
I would like to reproduce identical wordcloud images (same word positioning & colors) with different image dimensions. I don't want to control word positioning nor colors: I just want resulting cloud positions & colors to be repeatable across different runs of my script (or if someone else runs my code), at different image sizes.
I would expect changing width & height plus setting a
random_state
should be enough.Or maybe I just misunderstood what is
random_state
intended usage. I couldn't find it explained in documentation.Steps/Code to Reproduce
Expected Results
Two identical wordclouds, except for image width and height. i.e. same result as if I first produce the big image and then I use image processing software to reduce its dimensions.
Actual Results
For a given size, the same image output is achieved (same colors and positions as in previous script runs).
But comparing different sized images, their colors and positions are different.
Versions
Windows-7-6.1.7601-SP1 Python 3.8.7 (tags/v3.8.7:6503f05, Dec 21 2020, 17:59:51) [MSC v.1928 64 bit (AMD64)] NumPy 1.22.4 matplotlib 3.6.3 wordcloud 1.9.1.1