如何使用python增加Word cloud中的最大单词数?

如何使用python增加Word cloud中的最大单词数?,python,scikit-learn,visualization,word-cloud,Python,Scikit Learn,Visualization,Word Cloud,我正在使用wordcloud实现 下面是我编写的代码,与他们提供的示例类似 from os import path from scipy.misc import imread import matplotlib.pyplot as plt import random from wordcloud import WordCloud, STOPWORDS def grey_color_func(word, font_size, position, orientation, random_sta

我正在使用wordcloud实现

下面是我编写的代码,与他们提供的示例类似

from os import path
from scipy.misc import imread
import matplotlib.pyplot as plt
import random

from wordcloud import WordCloud, STOPWORDS


def grey_color_func(word, font_size, position, orientation, random_state=None, **kwargs):
    return "hsl(0, 0%%, %d%%)" % random.randint(60, 100)

d = path.dirname(__file__)


with open("sample.csv") as f:
    lines = f.readlines() 
text = "".join(lines)
f.close()

stopwords = STOPWORDS.copy()



wc = WordCloud(max_words=15156633, stopwords=stopwords, margin=10,random_state=1).generate(text)
# generate_from_frequencies()
default_colors = wc.to_array()
plt.title("Custom colors")
plt.imshow(wc.recolor(color_func=grey_color_func, random_state=3))
wc.to_file("wordcloud_figure.png")
plt.axis("off")
plt.figure()
plt.title("Default colors")
plt.imshow(default_colors)
plt.axis("off")
plt.show()
我得到的结果如下:

不管
WordCloud()
函数的“max_words”(无论我是增加还是减少),我几乎看不到对最终输出的影响

有什么不对劲吗


另外,如何使用。

中提到的
从频率生成您正在使用哪个版本的wordcloud模块?在git版本中,默认情况下(
relative_scaling=0
),每个单词只有在不再适合时才应减小字体大小。

先生,很高兴见到您。我刚从Github下载,不确定版本。有什么办法可以避免这种情况吗?使用to_file()方法而不使用任何遮罩图片的彩色图形?这似乎很奇怪。你能在WordCloudGithub上打开一个问题并提供输入文本吗?不过,我不确定什么时候有时间调查。