Closed n3vrmr closed 1 year ago
I wanted to create a word cloud where the frequency of the words decided their color, as if it was a heatmap of sorts, but I can't figure out how to do it.
wc = WordCloud(background_color='black', stopwords=set(list(STOPWORDS)+additional_stopwords), height=600, width=800, min_font_size=5, max_words=100, colormap=sns.color_palette("Spectral", as_cmap=True), random_state=None) wc.generate(text) plt.imshow(wc) plt.axis("off") plt.show()
wc = WordCloud(background_color='black', stopwords=set(list(STOPWORDS)+additional_stopwords), height=600, width=800, min_font_size=5, max_words=100, colormap=sns.color_palette("Spectral", as_cmap=True), random_state=None)
wc.generate(text) plt.imshow(wc) plt.axis("off") plt.show()
Does the random_state argument do anything? Or should I use a different argument for the colors?
Sorry for the slow response. You can pass a custom color_func that maps the frequency to a color.
color_func
It is right there, in examples/a_new_order.py
Closing, let me know if there's more questions.
Description
I wanted to create a word cloud where the frequency of the words decided their color, as if it was a heatmap of sorts, but I can't figure out how to do it.
Does the random_state argument do anything? Or should I use a different argument for the colors?