From 759fda3aeb14a98bd5c096175c2b45e5cd75ac39 Mon Sep 17 00:00:00 2001 From: Neil Smith Date: Fri, 16 Mar 2018 20:29:39 +0000 Subject: [PATCH] Create a treemap of letter frequencies --- letter-treemap.png | Bin 0 -> 4501 bytes make-letter-frequency-treemap.ipynb | 237 ++++++++++++++++++++++++++++ 2 files changed, 237 insertions(+) create mode 100644 letter-treemap.png create mode 100644 make-letter-frequency-treemap.ipynb diff --git a/letter-treemap.png b/letter-treemap.png new file mode 100644 index 0000000000000000000000000000000000000000..6cde8ed9ee5546f9bceb37738489631186f08fa3 GIT binary patch literal 4501 zcmbtY2UHVVw+<08pfr(QRg|KD1yK+bRFEJ=YEYzl=_T~u1d*mh0s(2EcR~OOO}YvK z3Q|HOp@{-QNJ1wN$_w|ucm4PM@4oV{H*1}lIWv2oz4n>Czy0lreW-h%l|_IB006Lp zHSZY!01O=T`&|$d{oF>QnbI$eUU$GoAo>vu`Ynb&XLi?o}A<27sVXBz1@}M@ zyLNp069B-m3cjaitFS;`8;0er428F2T$`EL%`=T99kfb%LUQD4X_X7MD`9sC1`!Ufn>`U zr=44HC3>wG)|(<|9FZHq2dYv5gnMyv0J=aRz*9!X@XJ78J0Ams)yr_eB@I;o-&rxh z%cEl=V&I#{D{ECcnj8i1e?w0DL42QBlP1j`WSG6%Diwcz3cI+`nu*tf*WL;$t*J@X zf=f&HjYul#9;nRt>ZExf^l)fi28M_Afp(cFB)@%m(_Djv*>cs6w}8O~+$<-Pdm_wa zz@XfYgq6jZp`O6P0kYNB-7LZ~xAGX$&N`FQl{*2frqMyG;$XSStCkN;!b($wlhy|! zBu2`-YGmKI7Y*R%8G-WdmQXwzv8HgL%%efNx2)DzzwVZ0RiR1c7iPvw-u}>BWaFl- zjs?}8V5sXzz)uMHszYC;$!o&b@q6(j;+LC#mvny}(VXA3khxH2pQ)+}5H*6}etiT( zomRg_U)zJB%WEozHVd*p-B2+m@`T z&ow3>keUPbe2Q5ZG=O{WM5W;y_XXR={Vd6x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_7Nuf z?4q)}IXF`$&f4e;CozYgZQN%BwhKwT4$Lb`PkA3eE#~=KF8ybm z{YkZ_dfA+t{i5(lclglME#mTp?M!B*uU!h3qAk+b<6|dn-6mo zA-iLnCvFHGO5E0-x4DMBwzJf+pwwU+edfngAM%u&;X{WQ(j#{cT`^gcS~*MMediL{ zfDO*5d+H9jnrn3uhZ!5ME^$s$wxv*9s@2??d!F~3Fk^QqFYHoB+ny_*KqkxatrI7< zzeC$3#8l}9cud-RZamBBFxy;GMupl|llV16_K5xjF5TGQAw!ms*>XPZ8s%v6}@C62sO-pGRwPAhN z>m;t3W~zRjUh3)9r*%wl3+?Y^DAcPEy8YO?z%u!;1R3*EvR~$H8lEstW+U8q_RqHJ z-&psLg8g{|Dw*8kR;qB(GG}q|hnALWxmv!2q?j0;@U(M22?0ud9vDuLgE)Q8E?V%b zzg+~-3$H_2x&`q}^Htt@wlr1^J{r)NzVXQwUa(lE6?Ol5O*4x-8|2u%Rq6aK)s1)4 zo`k!A`<@$TwY3Pc_(p4t7EBl+jz|?U)VF>%YaH&?u)}yVH94>KY}bP5fKH-QGYja% zNc$kyDXt8wAc1MnAz#7tEfxEw?YRs9gnF>BOMu|JfAo?6a9AJ{XW2m5WWh=SYS>`r7FEvs!EL;#;2Wa^6L1JJKn1MtucUiZv0!BN-Uo(6F5%bdTZuVYpV z7e7}}wD2wQZVK<7GH~Wj(Aye}J&EU4z=Flm=qRU6pJ5~ON47ycq2iZ*MTcEeVPGgL zt*C97OQl!0JKP^_S>h9n+)YbZ+Q!hkUmEGTl?#eFUbsoBNMCenQP|N%1@D-j^U->% z!pt_i64+uvIO`VRSxI6Z4H%HD`9}ziAs=3dOA_qDO%|hDKNSx^`3~d&RS|z_&j0-= v`fF?dzi4CQMJrj`)Bb-^`#;$G)&>|WWA9w2y" + ] + }, + "metadata": {}, + "output_type": "display_data" + } + ], + "source": [ + "# If you have 2 lists\n", + "plt.rcParams[\"figure.figsize\"] = (4,4)\n", + "squarify.plot(sizes=cs, label=ls, alpha=.7 )\n", + "plt.axis('off')\n", + "plt.savefig('letter-treemap.png', bbox_inches='tight')\n", + "plt.show()" + ] + }, + { + "cell_type": "code", + "execution_count": 42, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "'treattlpis'" + ] + }, + "execution_count": 42, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "cat(random_english_letter() for _ in range(10))" + ] + }, + { + "cell_type": "code", + "execution_count": 46, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "'lbycjleuqz'" + ] + }, + "execution_count": 46, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "import random\n", + "import string\n", + "\n", + "cat(random.choices(string.ascii_lowercase, k=10))" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [] + } + ], + "metadata": { + "kernelspec": { + "display_name": "Python 3", + "language": "python", + "name": "python3" + }, + "language_info": { + "codemirror_mode": { + "name": "ipython", + "version": 3 + }, + "file_extension": ".py", + "mimetype": "text/x-python", + "name": "python", + "nbconvert_exporter": "python", + "pygments_lexer": "ipython3", + "version": "3.6.3" + } + }, + "nbformat": 4, + "nbformat_minor": 2 +} -- 2.34.1