Leveraging the full power of the word_cloud library
Attribution: Powered by the word_cloud library by Andreas Mueller
github.com/amueller/word_cloud
(MIT License)
Control how text is analyzed and processed
stopwords
Remove common words automatically
regexp
Custom text tokenization patterns
normalize_plurals
Treat singular/plural as same word
collocations
Detect and include word pairs
collocation_threshold
include_numbers
min_word_length
Fine-tune word placement and arrangement
prefer_horizontal
Control word orientation (0-1)
repeat
relative_scaling
Word size importance (0-1 or 'auto')
ranks_only
margin
scale
Customize fonts and text sizing
font_path
Use custom TTF/OTF fonts
font_step
min_font_size
max_font_size
Control colors and visual effects
colormap
60+ matplotlib color schemes
color_func
background_color
mode
contour_width
Outline around mask shape
contour_color
Set dimensions and output parameters
width
height
max_words
mask
Custom shapes from images
random_state
Reproducible layouts
Export in multiple formats including SVG
to_image()
Export as PIL Image
to_array()
Export as numpy array
to_file()
Save as PNG/JPG
to_svg()
Export as scalable vector
Advanced color customization functions
ImageColorGenerator
Extract colors from image
get_single_color_func
Single hue variations
grey_color_func
Random grey shades
rainbow_color_func
Position-based rainbow
size_color_func
Size-based coloring
Parameter | Type | Default | Description |
---|---|---|---|
width |
int | 400 | Canvas width in pixels |
height |
int | 200 | Canvas height in pixels |
max_words |
int | 200 | Maximum number of words |
relative_scaling |
float/'auto' | 'auto' | Word frequency importance (0-1) |
min_font_size |
int | 4 | Smallest font size |
font_step |
int | 1 | Font size iteration step |
prefer_horizontal |
float | 0.9 | Horizontal text preference (0-1) |
mask |
ndarray | None | Binary mask for custom shapes |
scale |
float | 1 | Scaling between computation and drawing |
stopwords |
set | STOPWORDS | Words to exclude |
from wordcloud import WordCloud
# Generate from text
wordcloud = WordCloud(width=800, height=400).generate(text)
wordcloud.to_file("output.png")
# Use matplotlib colormap
wordcloud = WordCloud(colormap='viridis').generate(text)
# Use custom color function
def custom_color_func(word, **kwargs):
return f"hsl({random.randint(0, 360)}, 70%, 50%)"
wordcloud = WordCloud(color_func=custom_color_func).generate(text)
# Use custom shape
from PIL import Image
import numpy as np
mask = np.array(Image.open("shape.png"))
wordcloud = WordCloud(mask=mask, contour_width=3).generate(text)
WordCloud Studio implements all features from the word_cloud library
Created with ❤️ by temp188.com