word_cloud README

The project's README from github.com/amueller/word_cloud. As one markdown file: README.md.

licence DOI

word_cloud

A little word cloud generator in Python. Read more about it on the blog post or the website.

The code is tested against Python 3.7, 3.8, 3.9, 3.10, 3.11, 3.12, 3.13.

Installation

If you are using pip:

pip install wordcloud

If you are using conda, you can install from the conda-forge channel:

conda install -c conda-forge wordcloud

Installation notes

wordcloud depends on numpy, pillow, and matplotlib.

If there are no wheels available for your version of python, installing the package requires having a C compiler set up. Before installing a compiler, report an issue describing the version of python and operating system being used.

Examples

Check out examples/simple.py for a short intro. A sample output is:

Constitution

Or run examples/masked.py to see more options. A sample output is:

Alice in Wonderland

Getting fancy with some colors: Parrot with rainbow colors

Generating wordclouds for Arabic:

Arabic wordlcloud

Command-line usage

The wordcloud_cli tool can be used to generate word clouds directly from the command-line:

$ wordcloud_cli --text mytext.txt --imagefile wordcloud.png

If you're dealing with PDF files, then pdftotext, included by default with many Linux distribution, comes in handy:

$ pdftotext mydocument.pdf - | wordcloud_cli --imagefile wordcloud.png

In the previous example, the - argument orders pdftotext to write the resulting text to stdout, which is then piped to the stdin of wordcloud_cli.py.

Use wordcloud_cli --help so see all available options.

Licensing

The wordcloud library is MIT licenced, but contains DroidSansMono.ttf, a true type font by Google, that is apache licensed. The font is by no means integral, and any other font can be used by setting the font_path variable when creating a WordCloud object.

word_cloud (amueller/word_cloud)

Searching Database…

What is this?word_cloud is a little word cloud generator in Python: it turns a body of text into an image where each word is sized by how often it appears. It works as a Python library and also ships a small command-line tool called wordcloudcli.
Is it a library or a command-line tool?Both. In Python code you create a WordCloud object and render it with matplotlib; the same package also installs wordcloudcli so you can generate a cloud straight from the shell.
How do I get it into my environment?With pip run pip install wordcloud, or if you use conda install it from the conda-forge channel: conda install -c conda-forge wordcloud.
What does it pull in alongside it?It depends on numpy, pillow, and matplotlib — pip and conda fetch these automatically during installation.
Will it install cleanly on any setup?Mostly yes: the code is tested against Python 3.7 through 3.13. The catch is that if no prebuilt wheel exists for your Python version and OS, installing the package requires having a C compiler set up first.
Is the license safe for my own project?The library itself is MIT licensed, but it bundles DroidSansMono.ttf, a Google font that is Apache licensed. The font is not integral — set the fontpath variable when creating a WordCloud object to swap in any other font.
Can I generate a cloud from a text file without writing code?Yes — the package includes wordcloudcli. Run wordcloudcli --text mytext.txt --imagefile wordcloud.png, and use wordcloudcli --help to see all options. For PDFs, pipe pdftotext into it: pdftotext mydocument.pdf - | wordcloudcli --imagefile wordcloud.png.
What can the output look like beyond a plain rectangle of words?The examples show several styles: simple.py is a short intro, masked.py fits the cloud to a mask shape, there is a variant getting fancy with colors, and one for generating wordclouds for Arabic.
Can I use my own font?Yes. The default bundled font is DroidSansMono.ttf by Google, but it is by no means integral — set the fontpath variable when creating a WordCloud object to use any other TrueType font.
Creator
amueller
Size
117 MB
Stars
10.5K
Age
13y
Commits · 90 Days