I have this wordcloud . What are other color schemas and styles that I can adjust? Here…
- User
I have this wordcloud . What are other color schemas and styles that I can adjust?
Here is the code:
""" def create_wordcloud(df): """ Generate and save a Hebrew word cloud from cleaned text. """ text = " ".join(df['clean_output'].tolist()) wc = WordCloud(width=1600, height=900, background_color="white", font_path="/XXX.ttf").generate(text) plt.figure(figsize=(12, 8)) plt.imshow(wc, interpolation="bilinear") plt.axis("off") plt.tight_layout() plt.savefig("minimal_prompt_wordcloud.png")"""
- Assistant
Nice — your word cloud looks great! You can customize colors, shapes, and styles in WordCloud quite a bit. Here are some main options you can experiment with:
🎨 Color Schemes You can change the colors using the colormap argument: pythonCopy codewc = WordCloud( width=1600, height=900, background_color="white", colormap="viridis", # try different ones font_path="/XXX.ttf" ).generate(text)
Some popular colormaps (from Matplotlib): CategoryExamplesSequential"Blues", "Greens", "Purples", "Oranges", "Reds"Diverging"coolwarm", "Spectral", "RdYlBu", "PiYG", "BrBG"Cyclic"twilight", "hsv"Qualitative"tab10", "Set2", "Accent", "Paired", "Dark2" Example: pythonCopy codecolormap="tab10"
- User
No. How can I ajust the number of words?
- Assistant
Good — that’s an easy and useful one ✅ You can control the number of words in the cloud using the max_words parameter of WordCloud.
Example: pythonCopy codewc = WordCloud( width=1600, height=900, background_color="white", font_path="/XXX.ttf", max_words=100 # <– show up to 100 most frequent words ).generate(text)
Tips:
Default: max_words=200
Increasing it (max_words=500) → more dense, smaller words
Decreasing it (max_words=50) → cleaner, emphasizes top words
You can combine it with: pythonCopy codemin_font_size=10, max_font_size=200,
to fine-tune readability.
Would you like to make it automatically adjust (e.g., show all words above a certain frequency instead of a fixed count)?
- User
Can you make a loop that creates wordclouds of multiple sizes?
- Assistant
Absolutely 👍 — here’s a clean example that will generate multiple word clouds, each with a different number of words, and save them with filenames like wordcloud_50.png, wordcloud_100.png, etc.
✅ Example Code pythonCopy codefrom wordcloud import WordCloud import matplotlib.pyplot as plt
def create_wordclouds(df, max_words_list): """ Generate and save Hebrew word clouds for different word counts. """ text = " ".join(df['clean_output'].tolist())
codefor n in max_words_list: wc = WordCloud( width=1600, height=900, background_color="white", font_path="/XXX.ttf", max_words=n, colormap="viridis" # you can change this ).generate(text) plt.figure(figsize=(12, 8)) plt.imshow(wc, interpolation="bilinear") plt.axis("off") plt.tight_layout() filename = f"wordcloud_{n}.png" plt.savefig(filename) plt.close() print(f"Saved {filename}")