Some Alternative (Fun?) Displays

Lynn Cherny (arnicas@gmail.com)

Some of the criticism of wordclouds includes the random layout. Suppose we used a more strict layout? Say, ordering the words in terms of frequency. You can try it with the analytic_wordlist.html file. You need to edit in your file names again.

Suppose you wanted something more fun than a regular wordcloud? Of course you do... We can use text on a path, too. Here's an animated spiral you might like, in spiral_animated.html.

If you want to put your text onto an arbitrary SVG path, you can! You'll need to put a path into the file text_on_path.html.

If you want to create one online, you can draw something swoopy with the tool at http://www.drawsvg.org/.

Click on "draw" on the menu bar. You want to choose the free path tool:

Some tips: Set the size to something not too giant (like 700x500) in the Document menu Dimensions option:

When you're done with a swoopy shape, save it. You can save the file, or open it in a new window.

If you open it in a new window, you want to view source and copy this part out:

<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="900px" height="830px" viewBox="0 0 900 830" preserveAspectRatio="xMidYMid meet"  ><rect id="svgEditorBackground" x="0" y="0" width="1310" height="830" style="fill: none; stroke: none;"/><path d="M153.78678537677433,4.380506057513401c46.69999999999999,4,93.19999999999999,9.599999999999994,140,12c315.9,6.900000000000006,368.9,1.5999999999999943,685,11c23.899999999999977,2.4000000000000057,50.90000000000009,-0.20000000000000284,71,13c10.5,6.800000000000011,22.09999999999991,18.599999999999994,21,31c-1.2000000000000455,13.400000000000006,-17,21.30000000000001,-28,29c-20.59999999999991,14.300000000000011,-45.10000000000002,22.599999999999994,-69,30c-26.600000000000023,8.300000000000011,-54.200000000000045,14.099999999999994,-82,16c-210,-5.6999999999999895,-262,-16.5,-471,-27c-40.30000000000001,-1.1999999999999886,-82.5,-12,-121,0c-5,1.5999999999999943,-10.300000000000011,4.5,-13,9c-2.6000000000000227,4.300000000000011,-3.3999999999999773,10.199999999999989,-2,15c3.3000000000000114,11.300000000000011,13.699999999999989,19.69999999999999,23,27c21.100000000000023,16.5,46.10000000000002,29.19999999999999,72,36c149.20000000000005,17.399999999999977,200.79999999999995,4.6999999999999895,349,18c46.5,7.600000000000023,93,9.699999999999989,136,38c7.7999999999999545,6.899999999999977,14.700000000000045,18.899999999999977,12,29c-3.7000000000000455,13.800000000000011,-20.899999999999977,20.30000000000001,-34,26c-37.799999999999955,16.5,-80.89999999999998,17.19999999999999,-122,21c-109.10000000000002,5.6999999999999895,-161.5,-4,-271,4c-16.399999999999977,2.3000000000000114,-37.19999999999999,0.39999999999997743,-48,13c-3.8999999999999773,4.600000000000023,-3.6000000000000227,12.199999999999989,-2,18c2.8000000000000114,10.399999999999977,10.899999999999977,18.899999999999977,19,26c15.100000000000023,13.300000000000011,33.60000000000002,23.5,53,29c47.5,12.799999999999955,96.70000000000005,9.299999999999955,145,7c29.899999999999977,-1.5,70.89999999999998,-10.399999999999977,89,-13" stroke="black" id="e1_freepath" style="fill: none; stroke-width: 1px;" transform="matrix(0.970441 0 0 0.970441 82.4634 -50.0441)"/></svg>

In your text editor, copy that into the file text_on_path.html in the html section.

Also, notice the name of the id in that SVG -- "e1_freepath". If that is different in your HTML file, you need to change it in the code here:

var svg_id = "e1_freepath";

Also make sure to pass in your data file name in the bottom of the file.

queue()
  .defer(d3.text, "emma_word_counts.csv")
  .await(process);

You can also fiddle with the number of words shown in the var wordsToShow. Your largest numbers should probably appear.

Python Word Clouds

The best library is here (https://github.com/amueller/word_cloud) and some hacks on using it well with masks: http://minimaxir.com/2016/05/wordclouds/

For instance, you can use a font Awesome smiley face as a mask on positive yelp review words:

We're not doing those here because I didn't want us to have to install stuff for it, but they're fun!


In [ ]: