

{"id":4183,"date":"2016-03-19T06:46:39","date_gmt":"2016-03-19T11:46:39","guid":{"rendered":"http:\/\/rud.is\/b\/?p=4183"},"modified":"2018-08-11T20:45:12","modified_gmt":"2018-08-12T01:45:12","slug":"using-propublica-statefaces-in-ggplot2","status":"publish","type":"post","link":"https:\/\/rud.is\/b\/2016\/03\/19\/using-propublica-statefaces-in-ggplot2\/","title":{"rendered":"Using ProPublica &#8220;statefaces&#8221; in ggplot2"},"content":{"rendered":"<blockquote><p>\n  UPDATE: The dev version of <a href=\"https:\/\/github.com\/hrbrmstr\/ggalt\"><code>ggalt<\/code><\/a> has a new <code>geom_stateface()<\/code> which encapsulates the tedious bits and also included the TTF font.\n<\/p><\/blockquote>\n<p>I&#8217;m a <em>huge fan<\/em> of <a href=\"https:\/\/www.propublica.org\/\">ProPublica<\/a>. They have a super-savvy tech team, great reporters, awesome graphics folks and excel at data-driven journalism. Plus, they give away virtually <em>everything<\/em>, including data, text, graphics &amp; tools.<\/p>\n<p>I was reading @USATODAY&#8217;s piece on <a href=\"http:\/\/www.usatoday.com\/story\/news\/2016\/03\/11\/nearly-2000-water-systems-fail-lead-tests\/81220466\/\">lead levels in drinking water across America<\/a> and saw they had a mini-interactive piece included with their findings. A quick view in Developer Tools revealed the JSON and an equally quick use of <a href=\"https:\/\/github.com\/hrbrmstr\/curlconverter\"><code>curlconverter<\/code><\/a> had the <a href=\"https:\/\/gist.github.com\/hrbrmstr\/47c7a8d92ba066a8add7\">data behind the interactive<\/a> loaded into R in seconds (though it turns out just the straight URL to the JSON file works without the extra <code>cURL<\/code> parameters).<\/p>\n<p>I wanted to grab the data since, while I feel bad about Texas having 183 testing exceedances, I wanted to see if there&#8217;s a worse story if you normalize by population. I performed such a normalization by state (normalizing to per-100k population), but the data includes county information so a logical &amp; necessary next step is to do that calculation as well (which a task left for another day since I think it&#8217;ll require some more munging as they used county names vs FIPS codes in the JSON and I suspect the names aren&#8217;t prefect). If any reader jumps in to do the county analysis before I do, drop a note here and I&#8217;ll update the post with a link to it. Here&#8217;s the outcome (top 10 worst states, normalized by population):<\/p>\n<p><a href=\"https:\/\/i0.wp.com\/rud.is\/b\/wp-content\/uploads\/2016\/03\/Plot_Zoom.png?ssl=1\" rel=\"attachment wp-att-4187\"><img data-recalc-dims=\"1\" loading=\"lazy\" decoding=\"async\" width=\"510\" height=\"392\" data-attachment-id=\"4187\" data-permalink=\"https:\/\/rud.is\/b\/2016\/03\/19\/using-propublica-statefaces-in-ggplot2\/plot_zoom-5\/\" data-orig-file=\"https:\/\/i0.wp.com\/rud.is\/b\/wp-content\/uploads\/2016\/03\/Plot_Zoom.png?fit=1206%2C926&amp;ssl=1\" data-orig-size=\"1206,926\" data-comments-opened=\"1\" data-image-meta=\"{&quot;aperture&quot;:&quot;0&quot;,&quot;credit&quot;:&quot;&quot;,&quot;camera&quot;:&quot;&quot;,&quot;caption&quot;:&quot;&quot;,&quot;created_timestamp&quot;:&quot;0&quot;,&quot;copyright&quot;:&quot;&quot;,&quot;focal_length&quot;:&quot;0&quot;,&quot;iso&quot;:&quot;0&quot;,&quot;shutter_speed&quot;:&quot;0&quot;,&quot;title&quot;:&quot;&quot;,&quot;orientation&quot;:&quot;0&quot;}\" data-image-title=\"Plot_Zoom\" data-image-description=\"\" data-image-caption=\"\" data-large-file=\"https:\/\/i0.wp.com\/rud.is\/b\/wp-content\/uploads\/2016\/03\/Plot_Zoom.png?fit=510%2C392&amp;ssl=1\" src=\"https:\/\/i0.wp.com\/rud.is\/b\/wp-content\/uploads\/2016\/03\/Plot_Zoom.png?resize=510%2C392&#038;ssl=1\" alt=\"Plot_Zoom\" class=\"aligncenter size-full wp-image-4187\" \/><\/a><\/p>\n<p>Even at the county-level, the normalization isn&#8217;t perfect since these are testing levels at specific locations per water provider in a county. But, I made an assumption (it may be wrong, I don&#8217;t do macro-level water quality analysis for a living) that 94 exceedances in a small (both in size &amp; population) state like mine (Maine) is probably worse than 183 exceedances across a population the size of Texas. I think I&#8217;d need to take population density per county area into account to fully address this, but this is a first stab at the data and this post was written to talk about how to use ProPublica&#8217;s <a href=\"https:\/\/propublica.github.io\/stateface\/\">stateface font<\/a> in R vs do investigative data journalism :-)<\/p>\n<h3>What&#8217;s a &#8216;stateface&#8217;?<\/h3>\n<p>The fine folks at ProPublica took the Natural Earth shapefiles and made an icon font out of them. They have full code (with some super spiffy, clean, readable C code you can reuse) in their <a href=\"https:\/\/github.com\/propublica\/stateface\">github repo<\/a>, but they also provide <a href=\"http:\/\/propublica.github.com\/stateface\/pkg\/stateface.zip\">just the font<\/a>. However, it&#8217;s in OTF format and R kinda needs it in TTF format for widest graphics device support, so I <a href=\"http:\/\/rud.is\/dl\/StateFace-Regular.ttf\">converted it for you<\/a> (&amp; don&#8217;t get me started about fonts in R). You&#8217;ll need that font loaded to run the example. Note that ProPublica is still the <a href=\"https:\/\/raw.githubusercontent.com\/propublica\/stateface\/master\/LICENSE.txt\">license owner<\/a> of that converted font (both the OTF &amp; TTF are free to use, but give credit where it&#8217;s due&hellip;they did all the hard work). Aannnd it looks like they <a href=\"https:\/\/github.com\/propublica\/stateface\/tree\/master\/font\/webfont\">already had it created<\/a> (I had only looked at the zip file).<\/p>\n<p>ProPublica provides many support files to use these on the web, since that&#8217;s their target environment. They do provide key mappings for the font, which makes it usable in virtually any context fonts are supported. We&#8217;ll take advantage of those mappings in a bit, but you should check out their link above, they have some neat examples using these shapes as &#8220;sparkmaps&#8221; (i.e. inline in a sentence).<\/p>\n<h3>Using &#8216;stateface&#8217; in R<\/h3>\n<p>After loading the font into your system, it&#8217;s super-easy to use it in R. The font <code>family<\/code> name is &#8220;<code>StateFace-Regular<\/code>&#8221; and this is the translation table from 2-digit state abbreviation to glyph character:<\/p>\n<pre><code class=\"language-r\">state_trans <- c(AL='B', AK='A', AZ='D', AR='C', CA='E', CO='F', CT='G', \n                 DE='H', DC='y', FL='I', GA='J', HI='K', ID='M', IL='N', \n                 IN='O', IA='L', KS='P', KY='Q', LA='R', ME='U', MD='T',\n                 MA='S', MI='V', MN='W', MS='Y', MO='X', MT='Z', NE='c',\n                 NV='g', NH='d', NJ='e', NM='f', NY='h', NC='a', ND='b', \n                 OH='i', OK='j', OR='k', PA='l', RI='m', SC='n', SD='o',\n                 TN='p', TX='q', UT='r', VT='t', VA='s', WA='u', WV='w', \n                 WI='v', WY='x', US='z')<\/code><\/pre>\n<p>You now only need to do:<\/p>\n<pre><code class=\"language-r\">state_trans[\"ME\"]\n##  ME \n## \"U\"<\/code><\/pre>\n<p>to get the mappings.<\/p>\n<p>This is the (annotated) code to generate the bar chart above:<\/p>\n<pre><code class=\"language-r\">library(dplyr)    # munging\nlibrary(ggplot2)  # plotting, req: devtools::intstall_github(\"hadley\/ggplot2\")\nlibrary(scales)   # plotting helpers\nlibrary(hrbrmisc) # my themes\n\n# read in exceedance state\/county data\ndat <- read.csv(\"http:\/\/rud.is\/dl\/h2olead.csv\", stringsAsFactors=FALSE)\n\n# this is how USA TODAY's computation works, I'm just following it\nxcd <- count(distinct(dat, state, county, name), state, wt=exceedances)\n\n# get U.S. state population estimates for 2015\nus_pop <- setNames(read.csv(\"http:\/\/www.census.gov\/popest\/data\/state\/totals\/2015\/tables\/NST-EST2015-01.csv\",\n                            skip=9, nrows=51, stringsAsFactors=FALSE, header=FALSE)[,c(1,9)],\n                   c(\"state_name\", \"pop\"))\nus_pop$state_name <- sub(\"^\\\\.\", \"\", us_pop$state_name)\nus_pop$pop <- as.numeric(gsub(\",\", \"\", us_pop$pop))\n\n# join them to the exceedance data\nstate_tbl <- data_frame(state_name=state.name, state=tolower(state.abb))\nus_pop <- left_join(us_pop, state_tbl)\nxcd <- left_join(xcd, us_pop)\n\n# compute the exceedance by 100k population &#038; order the\n# states by that so we get the right bar order in ggplot\nxcd$per100k <- (xcd$n \/ xcd$pop) * 100000\nxcd$state_name <- factor(xcd$state_name,\n                         levels=arrange(xcd, per100k)$state_name)\nxcd <- arrange(xcd, desc(state_name))\n\n# get the top 10 worse exceedances\ntop_10 <- head(xcd, 10)\n\n# map (heh) the stateface font glpyh character to the state 2-letter code\ntop_10$st <- state_trans[toupper(top_10$state)]\n\ngg <- ggplot(top_10, aes(x=state_name, y=per100k))\ngg <- gg + geom_bar(stat=\"identity\", width=0.75)\n\n# here's what you need to do to place the stateface glyphs\ngg <- gg + geom_text(aes(x=state_name, y=0.25, label=st),\n                     family=\"StateFace-Regular\", color=\"white\",\n                     size=5, hjust=0)\n\ngg <- gg + geom_text(aes(x=state_name, y=per100k,\n                         label=sprintf(\"%s total  \", comma(n))),\n                     hjust=1, color=\"white\", family=\"KerkisSans\", size=3.5)\ngg <- gg + scale_x_discrete(expand=c(0,0))\ngg <- gg + scale_y_continuous(expand=c(0,0))\ngg <- gg + coord_flip()\ngg <- gg + labs(x=NULL, y=NULL,\n                title=\"Lead in the water: A nationwide look; Top 10 impacted states\",\n                subtitle=\"Exceedance count adjusted per 100K population; total exceedance displayed\",\n                caption=\"Data from USA TODAY's compliation of EPA\u2019s Safe Drinking Water Information System (SDWIS) database.\")\n\n# you'll need the Kerkis font loaded to use this theme\n# http:\/\/myria.math.aegean.gr\/kerkis\/\ngg <- gg + theme_hrbrmstr_kerkis(grid=FALSE)\n\n# I neee to fiddle with the theme settings so these line height tweaks\n# aren't necessary in the future\ngg <- gg + theme(plot.caption=element_text(lineheight=0.7))\ngg <- gg + theme(plot.title=element_text(lineheight=0.7))\n\ngg <- gg + theme(axis.text.x=element_blank())\ngg <- gg + theme(panel.margin=margin(t=5, b=5, l=20, r=20, \"pt\"))\ngg<\/code><\/pre>\n<h3>Why 'stateface'?<\/h3>\n<p>People <em>love<\/em> maps and the bars seemed, well, <em>lonely<\/em> :-) Seriously, though, this (IMO) provides a nice trade off between full-on choropleths (which are usually not warranted) and bland, basic bars. The adornments here may help readers engage with the chart a bit more then they otherwise would.<\/p>\n<h3>Fin<\/h3>\n<p>As I stated, this analysis probably needs to be at the county population level to have the most efficacy, and you'd need to come up with a weighted roll-up mechanism to rank the states properly. I still think this naive normalization is better than using the raw exceednace counts, but I'd love to have comments from folks who do this macro water testing analysis for a living!<\/p>\n<p>Full code is <a href=\"https:\/\/gist.github.com\/hrbrmstr\/99608f5b87787c3b155d\">in this gist<\/a>.<\/p>\n<p>And, <em>woo hoo!<\/em>, Maine is #1 in blueberries, lobsters &amp; insane governors and #3 in dangerous lead levels in public water systems.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>UPDATE: The dev version of ggalt has a new geom_stateface() which encapsulates the tedious bits and also included the TTF font. I&#8217;m a huge fan of ProPublica. They have a super-savvy tech team, great reporters, awesome graphics folks and excel at data-driven journalism. Plus, they give away virtually everything, including data, text, graphics &amp; tools. [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":4187,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"jetpack_post_was_ever_published":false,"_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":false,"_jetpack_newsletter_tier_id":0,"_jetpack_memberships_contains_paywalled_content":false,"_jetpack_memberships_contains_paid_content":false,"activitypub_content_warning":"","activitypub_content_visibility":"","activitypub_max_image_attachments":3,"activitypub_interaction_policy_quote":"anyone","activitypub_status":"","footnotes":""},"categories":[678,673,674,753,91],"tags":[810],"class_list":["post-4183","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-data-visualization","category-datavis-2","category-dataviz","category-ggplot","category-r","tag-post"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.3 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>Using ProPublica &quot;statefaces&quot; in ggplot2 - rud.is<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/rud.is\/b\/2016\/03\/19\/using-propublica-statefaces-in-ggplot2\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Using ProPublica &quot;statefaces&quot; in ggplot2 - rud.is\" \/>\n<meta property=\"og:description\" content=\"UPDATE: The dev version of ggalt has a new geom_stateface() which encapsulates the tedious bits and also included the TTF font. I&#8217;m a huge fan of ProPublica. They have a super-savvy tech team, great reporters, awesome graphics folks and excel at data-driven journalism. Plus, they give away virtually everything, including data, text, graphics &amp; tools. [&hellip;]\" \/>\n<meta property=\"og:url\" content=\"https:\/\/rud.is\/b\/2016\/03\/19\/using-propublica-statefaces-in-ggplot2\/\" \/>\n<meta property=\"og:site_name\" content=\"rud.is\" \/>\n<meta property=\"article:published_time\" content=\"2016-03-19T11:46:39+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2018-08-12T01:45:12+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/i0.wp.com\/rud.is\/b\/wp-content\/uploads\/2016\/03\/Plot_Zoom.png?fit=1206%2C926&ssl=1\" \/>\n\t<meta property=\"og:image:width\" content=\"1206\" \/>\n\t<meta property=\"og:image:height\" content=\"926\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/png\" \/>\n<meta name=\"author\" content=\"hrbrmstr\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"hrbrmstr\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"3 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\\\/\\\/rud.is\\\/b\\\/2016\\\/03\\\/19\\\/using-propublica-statefaces-in-ggplot2\\\/#article\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/rud.is\\\/b\\\/2016\\\/03\\\/19\\\/using-propublica-statefaces-in-ggplot2\\\/\"},\"author\":{\"name\":\"hrbrmstr\",\"@id\":\"https:\\\/\\\/rud.is\\\/b\\\/#\\\/schema\\\/person\\\/d7cb7487ab0527447f7fda5c423ff886\"},\"headline\":\"Using ProPublica &#8220;statefaces&#8221; in ggplot2\",\"datePublished\":\"2016-03-19T11:46:39+00:00\",\"dateModified\":\"2018-08-12T01:45:12+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/rud.is\\\/b\\\/2016\\\/03\\\/19\\\/using-propublica-statefaces-in-ggplot2\\\/\"},\"wordCount\":800,\"commentCount\":3,\"publisher\":{\"@id\":\"https:\\\/\\\/rud.is\\\/b\\\/#\\\/schema\\\/person\\\/d7cb7487ab0527447f7fda5c423ff886\"},\"image\":{\"@id\":\"https:\\\/\\\/rud.is\\\/b\\\/2016\\\/03\\\/19\\\/using-propublica-statefaces-in-ggplot2\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/i0.wp.com\\\/rud.is\\\/b\\\/wp-content\\\/uploads\\\/2016\\\/03\\\/Plot_Zoom.png?fit=1206%2C926&ssl=1\",\"keywords\":[\"post\"],\"articleSection\":[\"Data Visualization\",\"DataVis\",\"DataViz\",\"ggplot\",\"R\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\\\/\\\/rud.is\\\/b\\\/2016\\\/03\\\/19\\\/using-propublica-statefaces-in-ggplot2\\\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/rud.is\\\/b\\\/2016\\\/03\\\/19\\\/using-propublica-statefaces-in-ggplot2\\\/\",\"url\":\"https:\\\/\\\/rud.is\\\/b\\\/2016\\\/03\\\/19\\\/using-propublica-statefaces-in-ggplot2\\\/\",\"name\":\"Using ProPublica \\\"statefaces\\\" in ggplot2 - rud.is\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/rud.is\\\/b\\\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\\\/\\\/rud.is\\\/b\\\/2016\\\/03\\\/19\\\/using-propublica-statefaces-in-ggplot2\\\/#primaryimage\"},\"image\":{\"@id\":\"https:\\\/\\\/rud.is\\\/b\\\/2016\\\/03\\\/19\\\/using-propublica-statefaces-in-ggplot2\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/i0.wp.com\\\/rud.is\\\/b\\\/wp-content\\\/uploads\\\/2016\\\/03\\\/Plot_Zoom.png?fit=1206%2C926&ssl=1\",\"datePublished\":\"2016-03-19T11:46:39+00:00\",\"dateModified\":\"2018-08-12T01:45:12+00:00\",\"breadcrumb\":{\"@id\":\"https:\\\/\\\/rud.is\\\/b\\\/2016\\\/03\\\/19\\\/using-propublica-statefaces-in-ggplot2\\\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/rud.is\\\/b\\\/2016\\\/03\\\/19\\\/using-propublica-statefaces-in-ggplot2\\\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/rud.is\\\/b\\\/2016\\\/03\\\/19\\\/using-propublica-statefaces-in-ggplot2\\\/#primaryimage\",\"url\":\"https:\\\/\\\/i0.wp.com\\\/rud.is\\\/b\\\/wp-content\\\/uploads\\\/2016\\\/03\\\/Plot_Zoom.png?fit=1206%2C926&ssl=1\",\"contentUrl\":\"https:\\\/\\\/i0.wp.com\\\/rud.is\\\/b\\\/wp-content\\\/uploads\\\/2016\\\/03\\\/Plot_Zoom.png?fit=1206%2C926&ssl=1\",\"width\":1206,\"height\":926},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/rud.is\\\/b\\\/2016\\\/03\\\/19\\\/using-propublica-statefaces-in-ggplot2\\\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\\\/\\\/rud.is\\\/b\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Using ProPublica &#8220;statefaces&#8221; in ggplot2\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/rud.is\\\/b\\\/#website\",\"url\":\"https:\\\/\\\/rud.is\\\/b\\\/\",\"name\":\"rud.is\",\"description\":\"&quot;In God we trust. All others must bring data&quot;\",\"publisher\":{\"@id\":\"https:\\\/\\\/rud.is\\\/b\\\/#\\\/schema\\\/person\\\/d7cb7487ab0527447f7fda5c423ff886\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\\\/\\\/rud.is\\\/b\\\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":[\"Person\",\"Organization\"],\"@id\":\"https:\\\/\\\/rud.is\\\/b\\\/#\\\/schema\\\/person\\\/d7cb7487ab0527447f7fda5c423ff886\",\"name\":\"hrbrmstr\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/i0.wp.com\\\/rud.is\\\/b\\\/wp-content\\\/uploads\\\/2023\\\/10\\\/ukr-shield.png?fit=460%2C460&ssl=1\",\"url\":\"https:\\\/\\\/i0.wp.com\\\/rud.is\\\/b\\\/wp-content\\\/uploads\\\/2023\\\/10\\\/ukr-shield.png?fit=460%2C460&ssl=1\",\"contentUrl\":\"https:\\\/\\\/i0.wp.com\\\/rud.is\\\/b\\\/wp-content\\\/uploads\\\/2023\\\/10\\\/ukr-shield.png?fit=460%2C460&ssl=1\",\"width\":460,\"height\":460,\"caption\":\"hrbrmstr\"},\"logo\":{\"@id\":\"https:\\\/\\\/i0.wp.com\\\/rud.is\\\/b\\\/wp-content\\\/uploads\\\/2023\\\/10\\\/ukr-shield.png?fit=460%2C460&ssl=1\"},\"description\":\"Don't look at me\u2026I do what he does \u2014 just slower. #rstats avuncular \u2022 ?Resistance Fighter \u2022 Cook \u2022 Christian \u2022 [Master] Chef des Donn\u00e9es de S\u00e9curit\u00e9 @ @rapid7\",\"sameAs\":[\"http:\\\/\\\/rud.is\"],\"url\":\"https:\\\/\\\/rud.is\\\/b\\\/author\\\/hrbrmstr\\\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Using ProPublica \"statefaces\" in ggplot2 - rud.is","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/rud.is\/b\/2016\/03\/19\/using-propublica-statefaces-in-ggplot2\/","og_locale":"en_US","og_type":"article","og_title":"Using ProPublica \"statefaces\" in ggplot2 - rud.is","og_description":"UPDATE: The dev version of ggalt has a new geom_stateface() which encapsulates the tedious bits and also included the TTF font. I&#8217;m a huge fan of ProPublica. They have a super-savvy tech team, great reporters, awesome graphics folks and excel at data-driven journalism. Plus, they give away virtually everything, including data, text, graphics &amp; tools. [&hellip;]","og_url":"https:\/\/rud.is\/b\/2016\/03\/19\/using-propublica-statefaces-in-ggplot2\/","og_site_name":"rud.is","article_published_time":"2016-03-19T11:46:39+00:00","article_modified_time":"2018-08-12T01:45:12+00:00","og_image":[{"width":1206,"height":926,"url":"https:\/\/i0.wp.com\/rud.is\/b\/wp-content\/uploads\/2016\/03\/Plot_Zoom.png?fit=1206%2C926&ssl=1","type":"image\/png"}],"author":"hrbrmstr","twitter_card":"summary_large_image","twitter_misc":{"Written by":"hrbrmstr","Est. reading time":"3 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/rud.is\/b\/2016\/03\/19\/using-propublica-statefaces-in-ggplot2\/#article","isPartOf":{"@id":"https:\/\/rud.is\/b\/2016\/03\/19\/using-propublica-statefaces-in-ggplot2\/"},"author":{"name":"hrbrmstr","@id":"https:\/\/rud.is\/b\/#\/schema\/person\/d7cb7487ab0527447f7fda5c423ff886"},"headline":"Using ProPublica &#8220;statefaces&#8221; in ggplot2","datePublished":"2016-03-19T11:46:39+00:00","dateModified":"2018-08-12T01:45:12+00:00","mainEntityOfPage":{"@id":"https:\/\/rud.is\/b\/2016\/03\/19\/using-propublica-statefaces-in-ggplot2\/"},"wordCount":800,"commentCount":3,"publisher":{"@id":"https:\/\/rud.is\/b\/#\/schema\/person\/d7cb7487ab0527447f7fda5c423ff886"},"image":{"@id":"https:\/\/rud.is\/b\/2016\/03\/19\/using-propublica-statefaces-in-ggplot2\/#primaryimage"},"thumbnailUrl":"https:\/\/i0.wp.com\/rud.is\/b\/wp-content\/uploads\/2016\/03\/Plot_Zoom.png?fit=1206%2C926&ssl=1","keywords":["post"],"articleSection":["Data Visualization","DataVis","DataViz","ggplot","R"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/rud.is\/b\/2016\/03\/19\/using-propublica-statefaces-in-ggplot2\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/rud.is\/b\/2016\/03\/19\/using-propublica-statefaces-in-ggplot2\/","url":"https:\/\/rud.is\/b\/2016\/03\/19\/using-propublica-statefaces-in-ggplot2\/","name":"Using ProPublica \"statefaces\" in ggplot2 - rud.is","isPartOf":{"@id":"https:\/\/rud.is\/b\/#website"},"primaryImageOfPage":{"@id":"https:\/\/rud.is\/b\/2016\/03\/19\/using-propublica-statefaces-in-ggplot2\/#primaryimage"},"image":{"@id":"https:\/\/rud.is\/b\/2016\/03\/19\/using-propublica-statefaces-in-ggplot2\/#primaryimage"},"thumbnailUrl":"https:\/\/i0.wp.com\/rud.is\/b\/wp-content\/uploads\/2016\/03\/Plot_Zoom.png?fit=1206%2C926&ssl=1","datePublished":"2016-03-19T11:46:39+00:00","dateModified":"2018-08-12T01:45:12+00:00","breadcrumb":{"@id":"https:\/\/rud.is\/b\/2016\/03\/19\/using-propublica-statefaces-in-ggplot2\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/rud.is\/b\/2016\/03\/19\/using-propublica-statefaces-in-ggplot2\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/rud.is\/b\/2016\/03\/19\/using-propublica-statefaces-in-ggplot2\/#primaryimage","url":"https:\/\/i0.wp.com\/rud.is\/b\/wp-content\/uploads\/2016\/03\/Plot_Zoom.png?fit=1206%2C926&ssl=1","contentUrl":"https:\/\/i0.wp.com\/rud.is\/b\/wp-content\/uploads\/2016\/03\/Plot_Zoom.png?fit=1206%2C926&ssl=1","width":1206,"height":926},{"@type":"BreadcrumbList","@id":"https:\/\/rud.is\/b\/2016\/03\/19\/using-propublica-statefaces-in-ggplot2\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/rud.is\/b\/"},{"@type":"ListItem","position":2,"name":"Using ProPublica &#8220;statefaces&#8221; in ggplot2"}]},{"@type":"WebSite","@id":"https:\/\/rud.is\/b\/#website","url":"https:\/\/rud.is\/b\/","name":"rud.is","description":"&quot;In God we trust. All others must bring data&quot;","publisher":{"@id":"https:\/\/rud.is\/b\/#\/schema\/person\/d7cb7487ab0527447f7fda5c423ff886"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/rud.is\/b\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":["Person","Organization"],"@id":"https:\/\/rud.is\/b\/#\/schema\/person\/d7cb7487ab0527447f7fda5c423ff886","name":"hrbrmstr","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/i0.wp.com\/rud.is\/b\/wp-content\/uploads\/2023\/10\/ukr-shield.png?fit=460%2C460&ssl=1","url":"https:\/\/i0.wp.com\/rud.is\/b\/wp-content\/uploads\/2023\/10\/ukr-shield.png?fit=460%2C460&ssl=1","contentUrl":"https:\/\/i0.wp.com\/rud.is\/b\/wp-content\/uploads\/2023\/10\/ukr-shield.png?fit=460%2C460&ssl=1","width":460,"height":460,"caption":"hrbrmstr"},"logo":{"@id":"https:\/\/i0.wp.com\/rud.is\/b\/wp-content\/uploads\/2023\/10\/ukr-shield.png?fit=460%2C460&ssl=1"},"description":"Don't look at me\u2026I do what he does \u2014 just slower. #rstats avuncular \u2022 ?Resistance Fighter \u2022 Cook \u2022 Christian \u2022 [Master] Chef des Donn\u00e9es de S\u00e9curit\u00e9 @ @rapid7","sameAs":["http:\/\/rud.is"],"url":"https:\/\/rud.is\/b\/author\/hrbrmstr\/"}]}},"jetpack_featured_media_url":"https:\/\/i0.wp.com\/rud.is\/b\/wp-content\/uploads\/2016\/03\/Plot_Zoom.png?fit=1206%2C926&ssl=1","jetpack_shortlink":"https:\/\/wp.me\/p23idr-15t","jetpack_likes_enabled":true,"jetpack-related-posts":[{"id":4429,"url":"https:\/\/rud.is\/b\/2016\/06\/12\/on-whether-y-axis-labels-are-always-necessary\/","url_meta":{"origin":4183,"position":0},"title":"On Whether Y-axis Labels Are Always Necessary","author":"hrbrmstr","date":"2016-06-12","format":false,"excerpt":"The infamous @albertocairo [blogged about](http:\/\/www.thefunctionalart.com\/2016\/06\/propublica-visualizes-seasonality-in.html) a [nice interactive piece on German company tax avoidance](https:\/\/projects.propublica.org\/graphics\/dividend) by @ProPublica. Here's a snapshot of their interactive chart: ![](https:\/\/2.bp.blogspot.com\/-S-8bu1UdYWM\/V1rXibnBxrI\/AAAAAAAAGo0\/L940SpU3DvUPX90JK82jrKQN6fWMyn2IACLcB\/s1600\/1prop.png) Dr. Cairo (his PhD is in the bag as far as I'm concerned :-) posited: >_Isn't it weird that the chart doesn't have a scale on\u2026","rel":"","context":"In &quot;Data Visualization&quot;","block_context":{"text":"Data Visualization","link":"https:\/\/rud.is\/b\/category\/data-visualization\/"},"img":{"alt_text":"","src":"https:\/\/i0.wp.com\/rud.is\/b\/wp-content\/uploads\/2016\/06\/Plot_Zoom.png?fit=1200%2C1036&ssl=1&resize=350%2C200","width":350,"height":200,"srcset":"https:\/\/i0.wp.com\/rud.is\/b\/wp-content\/uploads\/2016\/06\/Plot_Zoom.png?fit=1200%2C1036&ssl=1&resize=350%2C200 1x, https:\/\/i0.wp.com\/rud.is\/b\/wp-content\/uploads\/2016\/06\/Plot_Zoom.png?fit=1200%2C1036&ssl=1&resize=525%2C300 1.5x, https:\/\/i0.wp.com\/rud.is\/b\/wp-content\/uploads\/2016\/06\/Plot_Zoom.png?fit=1200%2C1036&ssl=1&resize=700%2C400 2x, https:\/\/i0.wp.com\/rud.is\/b\/wp-content\/uploads\/2016\/06\/Plot_Zoom.png?fit=1200%2C1036&ssl=1&resize=1050%2C600 3x"},"classes":[]},{"id":12510,"url":"https:\/\/rud.is\/b\/2019\/09\/14\/twitter-account-analysis-in-r\/","url_meta":{"origin":4183,"position":1},"title":"Twitter &#8220;Account Analysis&#8221; in R","author":"hrbrmstr","date":"2019-09-14","format":false,"excerpt":"This past week @propublica linked to a really spiffy resource for getting an overview of a Twitter user's profile and activity called accountanalysis. It has a beautiful interface that works as well on mobile as it does in a real browser. It also is fully interactive and supports cross-filtering (zoom\u2026","rel":"","context":"In &quot;R&quot;","block_context":{"text":"R","link":"https:\/\/rud.is\/b\/category\/r\/"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":5916,"url":"https:\/\/rud.is\/b\/2017\/05\/07\/plot-the-vote-making-u-s-senate-house-cartograms-in-r\/","url_meta":{"origin":4183,"position":2},"title":"Plot the Vote: Making U.S. Senate &#038; House Cartograms in R","author":"hrbrmstr","date":"2017-05-07","format":false,"excerpt":"Political machinations are a tad insane in the U.S. these days & I regularly hit up @ProPublica & @GovTrack sites (& sub to the GovTrack e-mail updates) as I try to be an informed citizen, especially since I've got a Senator and Representative who seem to be in the sway\u2026","rel":"","context":"In &quot;cartography&quot;","block_context":{"text":"cartography","link":"https:\/\/rud.is\/b\/category\/cartography\/"},"img":{"alt_text":"","src":"https:\/\/i0.wp.com\/rud.is\/b\/wp-content\/uploads\/2017\/05\/rep_gt-1.png?fit=1200%2C840&ssl=1&resize=350%2C200","width":350,"height":200,"srcset":"https:\/\/i0.wp.com\/rud.is\/b\/wp-content\/uploads\/2017\/05\/rep_gt-1.png?fit=1200%2C840&ssl=1&resize=350%2C200 1x, https:\/\/i0.wp.com\/rud.is\/b\/wp-content\/uploads\/2017\/05\/rep_gt-1.png?fit=1200%2C840&ssl=1&resize=525%2C300 1.5x, https:\/\/i0.wp.com\/rud.is\/b\/wp-content\/uploads\/2017\/05\/rep_gt-1.png?fit=1200%2C840&ssl=1&resize=700%2C400 2x, https:\/\/i0.wp.com\/rud.is\/b\/wp-content\/uploads\/2017\/05\/rep_gt-1.png?fit=1200%2C840&ssl=1&resize=1050%2C600 3x"},"classes":[]},{"id":2190,"url":"https:\/\/rud.is\/b\/2013\/02\/27\/follow-upresources-grc-t18-data-analysis-and-visualization-for-security-professionals-rsac\/","url_meta":{"origin":4183,"position":3},"title":"Follow up\/Resources :: GRC-T18 \u2013 Data Analysis and Visualization for Security Professionals #RSAC","author":"hrbrmstr","date":"2013-02-27","format":false,"excerpt":"Many thanks to all who attended the talk @jayjacobs & I gave at RSA on Tuesday, February 26, 2013. It was really great to be able to talk to so many of you afterwards as well. We've enumerated quite a bit of non-slide-but-in-presentation information that we wanted to aggregate into\u2026","rel":"","context":"In &quot;Charts &amp; Graphs&quot;","block_context":{"text":"Charts &amp; Graphs","link":"https:\/\/rud.is\/b\/category\/charts-graphs\/"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":2465,"url":"https:\/\/rud.is\/b\/2013\/04\/18\/sourceboston2013\/","url_meta":{"origin":4183,"position":4},"title":"SOURCE Boston (@SOURCEConf) Data Analysis &#038; Visualization Talk Resources #srcbos13","author":"hrbrmstr","date":"2013-04-18","format":false,"excerpt":"Many thanks to all who attended the talk @jayjacobs & I gave at @SOURCEconf on Thursday, April 18, 2013. As promised, here are the [slides](https:\/\/dl.dropboxusercontent.com\/u\/43553\/SOURCE-Boston-2013.pdf) which should be much less washed out than the projector version :-) We've enumerated quite a bit of non-slide-but-in-presentation information that we wanted to aggregate\u2026","rel":"","context":"In &quot;Big Data&quot;","block_context":{"text":"Big Data","link":"https:\/\/rud.is\/b\/category\/big-data\/"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":2499,"url":"https:\/\/rud.is\/b\/2013\/05\/15\/secure360\/","url_meta":{"origin":4183,"position":5},"title":"Secure360 (@Secure360) Data Analysis &#038; Visualization Talk Resources #Sec360","author":"hrbrmstr","date":"2013-05-15","format":false,"excerpt":"Many thanks to all who attended the talk @jayjacobs & I gave at @Secure360 on Wednesday, May 15, 2013. As promised, here are the [slides](https:\/\/dl.dropboxusercontent.com\/u\/43553\/Secure360-2013.pdf). We've enumerated quite a bit of non-slide-but-in-presentation information that we wanted to aggregate into a blog post so you can vi[sz] along at home. If\u2026","rel":"","context":"In &quot;Charts &amp; Graphs&quot;","block_context":{"text":"Charts &amp; Graphs","link":"https:\/\/rud.is\/b\/category\/charts-graphs\/"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]}],"jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/rud.is\/b\/wp-json\/wp\/v2\/posts\/4183","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/rud.is\/b\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/rud.is\/b\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/rud.is\/b\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/rud.is\/b\/wp-json\/wp\/v2\/comments?post=4183"}],"version-history":[{"count":0,"href":"https:\/\/rud.is\/b\/wp-json\/wp\/v2\/posts\/4183\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/rud.is\/b\/wp-json\/wp\/v2\/media\/4187"}],"wp:attachment":[{"href":"https:\/\/rud.is\/b\/wp-json\/wp\/v2\/media?parent=4183"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/rud.is\/b\/wp-json\/wp\/v2\/categories?post=4183"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/rud.is\/b\/wp-json\/wp\/v2\/tags?post=4183"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}