

- #WORD CLOUD PYTHON JUPYTER NOTEBOOK FULL#
- #WORD CLOUD PYTHON JUPYTER NOTEBOOK CODE#
- #WORD CLOUD PYTHON JUPYTER NOTEBOOK LICENSE#
While there are more effective ways to visualize word frequencies, word clouds can be beautiful.

#WORD CLOUD PYTHON JUPYTER NOTEBOOK CODE#
Thanks to the plethora of awesome Python packages it requires just a few lines of code to generate a shaped word cloud like the one above. Plt.annotate(footer, xy=(0, -.025), xycoords='axes fraction', fontsize=infosize, color=fontcolor) Plt.title(title, color=fontcolor, size=30, y=1.01) Plt.imshow(wordcloud.recolor(color_func=grey_color, random_state=3)) The remaining statements set the title, footer text, turn off the axis grid and eventually show the image. To achieve the custom font coloring imshow is passed the return value of the recolor method of the wordcloud object.

In the final code block, the matplotlib figure is set up. Mask=imread('img/sherlock-holmes-silhouette.png'), The silhouette in the mask image is black and the background must be white, not transparent. Now we can set up the wordcloud object passing our custom variables, which include the list of stopwords and the image to use as a mask to shape the graphic. With open('data/literature/complete-sherlock-holmes-canon.txt') as f:

def grey_color(word, font_size, position, orientation, random_state=None, **kwargs): Notice that the text is transformed to lowercase to make the frequency calculation done by the wordcloud package case insensitive.
#WORD CLOUD PYTHON JUPYTER NOTEBOOK LICENSE#
This is the ASCII version of the complete works without the table of contents at the beginning and the license note at the end of the downloaded file. Next the whole text is loaded into the variable text. By decreasing the lightness value darker shades of grey will be used to render the words. The function grey_color defined below is used for coloring the words and slightly modified from the example given in the wordcloud documentation.
#WORD CLOUD PYTHON JUPYTER NOTEBOOK FULL#
The full text of these works, which is in the public domain in Europe, can be downloaded from the website sherlock-holm.es. The canon of Sherlock Holmes consists of the 56 short stories and 4 novels written by Sir Arthur Conan Doyle. Word Cloud of the Most Frequent Words in the Canon of Sherlock Holmes
