Displaying results

The final task is to show the results. The csv files generated in the previous section is good enough for most cases, but sometimes a visual display can be more appealing. In this section, you'll see how to use the stylecloud module for generating word clouds.

From pypi: stylecloud:

Python package + CLI to generate stylistic wordclouds, including gradients and icon shapes!

stylecloud is a Python package that leverages the popular word_cloud package, adding useful features to create truly unique word clouds!

# virtual environment
$ pip install stylecloud

# normal environment
# use py instead of python3.9 for Windows
$ python3.9 -m pip install --user stylecloud

Note that the stylecloud module depends on many other modules, so don't be surprised if you see them getting installed.

$ pip show stylecloud | grep '^Requires:'
Requires: wordcloud, icon-font-to-png, palettable, fire, matplotlib

# wordcloud in turn depends on other modules and so on
$ pip show wordcloud | grep '^Requires:'
Requires: numpy, pillow, matplotlib

Word cloud

The program below is based on examples provided in the stylecloud GitHub repo. The csv files generated earlier can be directly passed to the file_path argument. The second column with number of votes will be considered as weights for the first column data. The shape of the word cloud image generated can be specified using the icon_name argument. One of the book icons listed in the free Font Awesome icons list is used here.

Rest of the arguments are self explanatory. See the GitHub repo linked above for more details and customization options.

# author_cloud.py
import stylecloud

ip_files = ('top_authors_2019.csv', 'top_authors_2021.csv')
op_files = ('top_authors_2019.png', 'top_authors_2021.png')

for ip_file, op_file in zip(ip_files, op_files):
                              icon_name='fas fa-book-open',

Here's the result for 2019 poll:

Word cloud for 2019 women author poll

Here's the result for 2021 poll:

Word cloud for 2021 women author poll