WordCloud
WordCloud is a Python library for generating word cloud images. It can turn text data into visually appealing word clouds.
Installation
Chinese text support requires an additional font path configuration.
Basic usage
Simple word cloud
Read from a file
Custom styles
Basic parameters
Color schemes
Advanced features
Use a mask image
Custom word frequencies
Stopword filtering
Chinese text processing
Use jieba for tokenization
Complete example
Practical tips
Multiple shapes
Common issues
Chinese text shows as squares
- Cause: no Chinese font specified
- Fix: set
font_path='simhei.ttf'
Common Chinese font paths
- Windows:
C:\Windows\Fonts\simhei.ttf
- Mac:
/System/Library/Fonts/PingFang.ttc
- Linux:
/usr/share/fonts/truetype/
References
Last modified on April 17, 2026