

{"id":13262,"date":"2022-01-04T11:32:01","date_gmt":"2022-01-04T16:32:01","guid":{"rendered":"https:\/\/rud.is\/b\/?p=13262"},"modified":"2022-01-04T11:32:01","modified_gmt":"2022-01-04T16:32:01","slug":"starting-2022-off-with-a-fairly-complex-ggplot2-recreation-plot","status":"publish","type":"post","link":"https:\/\/rud.is\/b\/2022\/01\/04\/starting-2022-off-with-a-fairly-complex-ggplot2-recreation-plot\/","title":{"rendered":"Starting 2022 Off With A Fairly Complex {ggplot2} Recreation Plot"},"content":{"rendered":"<p>The New York Times had a [tragic] <a href=\"https:\/\/www.nytimes.com\/interactive\/2021\/12\/28\/us\/covid-deaths.html\">story on Covid deaths<\/a> today and one of their plots really stuck with me for how well it told that part of the story.<\/p>\n<p><a href=\"https:\/\/i0.wp.com\/rud.is\/b\/wp-content\/uploads\/2022\/01\/2022-01-04-nyt.jpg?ssl=1\"><img data-recalc-dims=\"1\" loading=\"lazy\" decoding=\"async\" data-attachment-id=\"13263\" data-permalink=\"https:\/\/rud.is\/b\/2022\/01\/04\/starting-2022-off-with-a-fairly-complex-ggplot2-recreation-plot\/2022-01-04-nyt\/\" data-orig-file=\"https:\/\/i0.wp.com\/rud.is\/b\/wp-content\/uploads\/2022\/01\/2022-01-04-nyt.jpg?fit=707%2C986&amp;ssl=1\" data-orig-size=\"707,986\" 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=\"2022-01-04-nyt\" data-image-description=\"\" data-image-caption=\"\" data-medium-file=\"https:\/\/i0.wp.com\/rud.is\/b\/wp-content\/uploads\/2022\/01\/2022-01-04-nyt.jpg?fit=215%2C300&amp;ssl=1\" data-large-file=\"https:\/\/i0.wp.com\/rud.is\/b\/wp-content\/uploads\/2022\/01\/2022-01-04-nyt.jpg?fit=510%2C711&amp;ssl=1\" src=\"https:\/\/i0.wp.com\/rud.is\/b\/wp-content\/uploads\/2022\/01\/2022-01-04-nyt.jpg?resize=510%2C711&#038;ssl=1\" alt=\"NYT Chart on Covid Deaths\" width=\"510\" height=\"711\" class=\"aligncenter size-large wp-image-13263\" srcset=\"https:\/\/i0.wp.com\/rud.is\/b\/wp-content\/uploads\/2022\/01\/2022-01-04-nyt.jpg?resize=530%2C739&amp;ssl=1 530w, https:\/\/i0.wp.com\/rud.is\/b\/wp-content\/uploads\/2022\/01\/2022-01-04-nyt.jpg?resize=215%2C300&amp;ssl=1 215w, https:\/\/i0.wp.com\/rud.is\/b\/wp-content\/uploads\/2022\/01\/2022-01-04-nyt.jpg?resize=108%2C150&amp;ssl=1 108w, https:\/\/i0.wp.com\/rud.is\/b\/wp-content\/uploads\/2022\/01\/2022-01-04-nyt.jpg?resize=500%2C697&amp;ssl=1 500w, https:\/\/i0.wp.com\/rud.is\/b\/wp-content\/uploads\/2022\/01\/2022-01-04-nyt.jpg?resize=150%2C209&amp;ssl=1 150w, https:\/\/i0.wp.com\/rud.is\/b\/wp-content\/uploads\/2022\/01\/2022-01-04-nyt.jpg?resize=400%2C558&amp;ssl=1 400w, https:\/\/i0.wp.com\/rud.is\/b\/wp-content\/uploads\/2022\/01\/2022-01-04-nyt.jpg?resize=200%2C279&amp;ssl=1 200w, https:\/\/i0.wp.com\/rud.is\/b\/wp-content\/uploads\/2022\/01\/2022-01-04-nyt.jpg?w=707&amp;ssl=1 707w\" sizes=\"auto, (max-width: 510px) 100vw, 510px\" \/><\/a><\/p>\n<p>NOTE: The red panel highlights are off a bit as I manually typed the data in (I only did the recreation to keep {ggplot2} muscle memory as I hadn&#8217;t doe a major customization like this in quite some time).<\/p>\n<p>Only one {grid} hack (for the faceted X axis labels) too!<\/p>\n<p>Hopefully, I&#8217;ll have more real-world opportunity to build some detailed, properly-annotated {ggplot2} plots this year.<\/p>\n<p>Shout out to @ClausWilke for {ggtext} and all the folks who&#8217;ve made {ggplot2} such a powerful data visualization tool.<\/p>\n<pre><code class=\"language-r\">library(grid)\nlibrary(gtable)\nlibrary(hrbrthemes)\nlibrary(tidyverse)\n\ngtable_filter_remove &lt;- function (x, name, trim = FALSE) {\n  # https:\/\/stackoverflow.com\/a\/36780639\n  matches &lt;- !(x$layout$name %in% name)\n  x$layout &lt;- x$layout[matches, , drop = FALSE]\n  x$grobs &lt;- x$grobs[matches]\n  if (trim) \n    x &lt;- gtable_trim(x)\n  x\n}\n\nread.csv(text=\"race,age_group,before,after,cause\nWhite,Under 25,1,3,Covid-19 deaths increased as a share of deaths from all cause\nWhite,25-44,3,10,Covid-19 deaths increased as a share of deaths from all cause\nWhite,45-64,8,15,Covid-19 deaths increased as a share of deaths from all cause\nWhite,65-84,13,11,NA\nWhite,85+,14,6,NA\nHispanic,Under 25,3,4,Covid-19 deaths increased as a share of deaths from all cause\nHispanic,25-44,17,21,Covid-19 deaths increased as a share of deaths from all cause\nHispanic,45-64,33,26,NA\nHispanic,65-84,33,17,NA\nHispanic,85+,21,9,NA\nBlack,Under 25,1,3,Covid-19 deaths increased as a share of deaths from all cause\nBlack,25-44,7,13,Covid-19 deaths increased as a share of deaths from all cause\nBlack,45-64,15,17,Covid-19 deaths increased as a share of deaths from all cause\nBlack,65-84,20,12,Covid-19 deaths increased as a share of deaths from all cause\nBlack,85+,17,8,NA\nAsian,Under 25,2,4,Covid-19 deaths increased as a share of deaths from all cause\nAsian,25-44,12,14,Covid-19 deaths increased as a share of deaths from all cause\nAsian,45-64,21,13,NA\nAsian,65-84,23,8,NA\nAsian,85+,17,4,NA\") -&gt; xdf\n\nxdf %&gt;% \n  mutate(\n    before = before\/100,\n    after = after\/100,\n    age_group = fct_inorder(age_group),\n    race = factor(race, levels = rev(c(\"Asian\", \"Black\", \"Hispanic\", \"White\")))\n  ) -&gt; xdf\n\n{\n\n  ggplot( data = xdf) +\n    geom_rect(\n      data = xdf,\n      aes(\n        xmin = -Inf, xmax = Inf, ymin = -Inf, ymax = Inf,\n        fill = cause\n      ),\n      alpha = 1\/6, color = NA\n    ) +\n    geom_rect(\n      data = xdf %&gt;% \n        filter(\n          (race == \"White\" &amp; age_group %in% c(\"65-84\", \"85+\")) |\n            (race == \"Hispanic\" &amp; age_group %in% c(\"45-64\", \"65-84\", \"85+\")) |\n            (race == \"Black\" &amp; age_group %in% c(\"85+\")) |\n            (race == \"Asian\" &amp; age_group %in% c(\"45-64\", \"65-84\", \"85+\"))\n        ),\n      aes(\n        xmin = -Inf, xmax = Inf, ymin = -Inf, ymax = Inf\n      ),\n      fill = \"#999999\", alpha = 1\/6, color = NA\n    ) +\n    geom_segment(\n      aes(-Inf, xend = Inf, -Inf, yend= -Inf),\n      size = 0.25, color = \"black\"\n    ) +\n    geom_segment(\n      data = xdf, aes(\"1\", before, xend=\"2\", yend=after),\n      size = 0.25\n    ) +\n    geom_point(\n      data = xdf, aes(\"1\", before), \n      fill = \"#999999\", color = \"white\", size = 2, stroke = 0.5, shape = 21\n    ) +\n    geom_point(\n      data = xdf, aes(\"2\", after),\n      fill = \"#bb271a\", color = \"white\", size = 2, stroke = 0.5, shape = 21\n    ) +\n    geom_text(\n      data = xdf,\n      aes(\"1\", before+0.05, label = scales::percent(before, 1)),\n      color = \"#999999\", family = font_es_bold, fontface = \"bold\", size = 3\n    ) +\n    geom_text(\n      data = xdf,\n      aes(\"2\", after+0.05, label = scales::percent(after, 1)),\n      color = \"#bb271a\", family = font_es_bold, fontface = \"bold\", size = 3\n    ) +\n    scale_x_discrete(\n      expand = c(0, 0),\n      labels = c(\"&lt;span style='color:#999999'&gt;BEFORE&lt;\/span&gt;\", \"&lt;span style='color:#bb271a'&gt;AFTER&lt;\/a&gt;\")\n    ) +\n    scale_y_percent(\n      limits = c(-0.005, 0.405),\n      breaks = c(-0.005, 0.1, 0.2, 0.3, 0.405),\n      labels = c(\"\", \"\", \"\", \"\", \"40%\\nof deaths from\\nall causes for\\nthis group\")\n    ) +\n    scale_fill_manual(\n      name = NULL,\n      values = c(\"#bb271a\"),\n      na.translate = FALSE\n    ) +\n    coord_cartesian(clip = \"off\") +\n    facet_wrap(\n      facets = race~age_group, \n      scales = \"free_x\",\n      labeller = \\(labels, multi_line = TRUE){\n        labels &lt;- lapply(labels, as.character)\n        labels[[\"race\"]][c(1,2,4,5,6,7,9,10,11,12,14,15,16,17,19,20)] &lt;- \"\"\n        labels[[\"age_group\"]] &lt;- sprintf(\"&lt;span style='font-style:normal;font-weight:normal;'&gt;%s&lt;\/span&gt;\", labels[[\"age_group\"]])\n        labels[[\"race\"]][c(3,8,13,18)] &lt;- sprintf(\"&lt;span style='font-size:12pt;'&gt;**%s**&lt;\/span&gt;\", labels[[\"race\"]][c(3,8,13,18)])\n        labels\n      }\n    ) +\n    labs(\n      x = NULL, y = NULL,\n      title = \"Covid-19 deaths &lt;span style='color:#999999'&gt;before&lt;\/span&gt; and &lt;span style='color:#bb271a'&gt;after&lt;\/span&gt; universal adult vaccine eligibility\",\n      caption = \"Source: Provisional weekly death data from the C.D.C. through Nov. 27. Note: Only the four largest racial and ethnic groups are included. Universal vaccine eligibility was April 19, the date when all adults in the United States were eligible for vaccination.\"\n    ) +\n    theme_ipsum_es(grid=\"Y\", plot_title_size = 16) +\n    theme(\n      plot.title.position = \"plot\",\n      plot.title = ggtext::element_markdown(hjust = 0.5),\n      plot.caption = ggtext::element_textbox_simple(\n        hjust = 0, size = 8.5, family = font_es, color = \"#999999\",\n        margin = margin(t = 14)\n      ),\n      axis.ticks.x.bottom = ell(size = 0.25) ,\n      axis.line.x.bottom = ell(lineend = \"square\", size = 0.25),\n      axis.text.x.bottom = ggtext::element_markdown(size = 8, margin = margin(t = 6)),\n      axis.text.y.left = elt(size = 8, vjust = 1, lineheight = 0.875,  color = \"#999999\"),\n      strip.text.x = ggtext::element_markdown(hjust = 0.5, size = 10, family = font_es),\n      strip.text = ggtext::element_markdown(hjust = 0.5, size = 10, family = font_es),\n      panel.spacing.x = unit(\"40\", \"pt\"),\n      panel.spacing.y = unit(6, \"pt\"),\n      panel.border = elb(),\n      legend.position = \"top\"\n    ) -&gt; gg\n\n  grid.newpage()\n  grid.draw(\n    gtable_filter_remove(\n      x = ggplotGrob(gg),\n      name = c(sprintf(\"axis-b-%d-1\", 2:5), sprintf(\"axis-b-%d-2\", 2:5), sprintf(\"axis-b-%d-3\", 2:5), sprintf(\"axis-b-%d-4\", 2:5))\n    )\n  )\n\n}\n<\/code><\/pre>\n<p><a href=\"https:\/\/i0.wp.com\/rud.is\/b\/wp-content\/uploads\/2022\/01\/2022-01-04-ggplot2.jpg?ssl=1\"><img data-recalc-dims=\"1\" loading=\"lazy\" decoding=\"async\" data-attachment-id=\"13264\" data-permalink=\"https:\/\/rud.is\/b\/2022\/01\/04\/starting-2022-off-with-a-fairly-complex-ggplot2-recreation-plot\/2022-01-04-ggplot2\/\" data-orig-file=\"https:\/\/i0.wp.com\/rud.is\/b\/wp-content\/uploads\/2022\/01\/2022-01-04-ggplot2.jpg?fit=1428%2C1844&amp;ssl=1\" data-orig-size=\"1428,1844\" 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=\"2022-01-04-ggplot2\" data-image-description=\"\" data-image-caption=\"\" data-medium-file=\"https:\/\/i0.wp.com\/rud.is\/b\/wp-content\/uploads\/2022\/01\/2022-01-04-ggplot2.jpg?fit=232%2C300&amp;ssl=1\" data-large-file=\"https:\/\/i0.wp.com\/rud.is\/b\/wp-content\/uploads\/2022\/01\/2022-01-04-ggplot2.jpg?fit=510%2C658&amp;ssl=1\" src=\"https:\/\/i0.wp.com\/rud.is\/b\/wp-content\/uploads\/2022\/01\/2022-01-04-ggplot2.jpg?resize=510%2C658&#038;ssl=1\" alt=\"{ggplot2} recreation of NYT plot\" width=\"510\" height=\"658\" class=\"aligncenter size-large wp-image-13264\" srcset=\"https:\/\/i0.wp.com\/rud.is\/b\/wp-content\/uploads\/2022\/01\/2022-01-04-ggplot2.jpg?resize=530%2C684&amp;ssl=1 530w, https:\/\/i0.wp.com\/rud.is\/b\/wp-content\/uploads\/2022\/01\/2022-01-04-ggplot2.jpg?resize=232%2C300&amp;ssl=1 232w, https:\/\/i0.wp.com\/rud.is\/b\/wp-content\/uploads\/2022\/01\/2022-01-04-ggplot2.jpg?resize=116%2C150&amp;ssl=1 116w, https:\/\/i0.wp.com\/rud.is\/b\/wp-content\/uploads\/2022\/01\/2022-01-04-ggplot2.jpg?resize=768%2C992&amp;ssl=1 768w, https:\/\/i0.wp.com\/rud.is\/b\/wp-content\/uploads\/2022\/01\/2022-01-04-ggplot2.jpg?resize=1189%2C1536&amp;ssl=1 1189w, https:\/\/i0.wp.com\/rud.is\/b\/wp-content\/uploads\/2022\/01\/2022-01-04-ggplot2.jpg?resize=500%2C646&amp;ssl=1 500w, https:\/\/i0.wp.com\/rud.is\/b\/wp-content\/uploads\/2022\/01\/2022-01-04-ggplot2.jpg?resize=150%2C194&amp;ssl=1 150w, https:\/\/i0.wp.com\/rud.is\/b\/wp-content\/uploads\/2022\/01\/2022-01-04-ggplot2.jpg?resize=1200%2C1550&amp;ssl=1 1200w, https:\/\/i0.wp.com\/rud.is\/b\/wp-content\/uploads\/2022\/01\/2022-01-04-ggplot2.jpg?resize=400%2C517&amp;ssl=1 400w, https:\/\/i0.wp.com\/rud.is\/b\/wp-content\/uploads\/2022\/01\/2022-01-04-ggplot2.jpg?resize=800%2C1033&amp;ssl=1 800w, https:\/\/i0.wp.com\/rud.is\/b\/wp-content\/uploads\/2022\/01\/2022-01-04-ggplot2.jpg?resize=200%2C258&amp;ssl=1 200w, https:\/\/i0.wp.com\/rud.is\/b\/wp-content\/uploads\/2022\/01\/2022-01-04-ggplot2.jpg?w=1428&amp;ssl=1 1428w, https:\/\/i0.wp.com\/rud.is\/b\/wp-content\/uploads\/2022\/01\/2022-01-04-ggplot2.jpg?w=1020&amp;ssl=1 1020w\" sizes=\"auto, (max-width: 510px) 100vw, 510px\" \/><\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>The New York Times had a [tragic] story on Covid deaths today and one of their plots really stuck with me for how well it told that part of the story. NOTE: The red panel highlights are off a bit as I manually typed the data in (I only did the recreation to keep {ggplot2} [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":13264,"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":[753,91],"tags":[],"class_list":["post-13262","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-ggplot","category-r"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.2 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>Starting 2022 Off With A Fairly Complex {ggplot2} Recreation Plot - 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\/2022\/01\/04\/starting-2022-off-with-a-fairly-complex-ggplot2-recreation-plot\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Starting 2022 Off With A Fairly Complex {ggplot2} Recreation Plot - rud.is\" \/>\n<meta property=\"og:description\" content=\"The New York Times had a [tragic] story on Covid deaths today and one of their plots really stuck with me for how well it told that part of the story. NOTE: The red panel highlights are off a bit as I manually typed the data in (I only did the recreation to keep {ggplot2} [&hellip;]\" \/>\n<meta property=\"og:url\" content=\"https:\/\/rud.is\/b\/2022\/01\/04\/starting-2022-off-with-a-fairly-complex-ggplot2-recreation-plot\/\" \/>\n<meta property=\"og:site_name\" content=\"rud.is\" \/>\n<meta property=\"article:published_time\" content=\"2022-01-04T16:32:01+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/i0.wp.com\/rud.is\/b\/wp-content\/uploads\/2022\/01\/2022-01-04-ggplot2.jpg?fit=1428%2C1844&ssl=1\" \/>\n\t<meta property=\"og:image:width\" content=\"1428\" \/>\n\t<meta property=\"og:image:height\" content=\"1844\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/jpeg\" \/>\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=\"4 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\/\/rud.is\/b\/2022\/01\/04\/starting-2022-off-with-a-fairly-complex-ggplot2-recreation-plot\/#article\",\"isPartOf\":{\"@id\":\"https:\/\/rud.is\/b\/2022\/01\/04\/starting-2022-off-with-a-fairly-complex-ggplot2-recreation-plot\/\"},\"author\":{\"name\":\"hrbrmstr\",\"@id\":\"https:\/\/rud.is\/b\/#\/schema\/person\/d7cb7487ab0527447f7fda5c423ff886\"},\"headline\":\"Starting 2022 Off With A Fairly Complex {ggplot2} Recreation Plot\",\"datePublished\":\"2022-01-04T16:32:01+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/rud.is\/b\/2022\/01\/04\/starting-2022-off-with-a-fairly-complex-ggplot2-recreation-plot\/\"},\"wordCount\":127,\"commentCount\":4,\"publisher\":{\"@id\":\"https:\/\/rud.is\/b\/#\/schema\/person\/d7cb7487ab0527447f7fda5c423ff886\"},\"image\":{\"@id\":\"https:\/\/rud.is\/b\/2022\/01\/04\/starting-2022-off-with-a-fairly-complex-ggplot2-recreation-plot\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/i0.wp.com\/rud.is\/b\/wp-content\/uploads\/2022\/01\/2022-01-04-ggplot2.jpg?fit=1428%2C1844&ssl=1\",\"articleSection\":[\"ggplot\",\"R\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\/\/rud.is\/b\/2022\/01\/04\/starting-2022-off-with-a-fairly-complex-ggplot2-recreation-plot\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/rud.is\/b\/2022\/01\/04\/starting-2022-off-with-a-fairly-complex-ggplot2-recreation-plot\/\",\"url\":\"https:\/\/rud.is\/b\/2022\/01\/04\/starting-2022-off-with-a-fairly-complex-ggplot2-recreation-plot\/\",\"name\":\"Starting 2022 Off With A Fairly Complex {ggplot2} Recreation Plot - rud.is\",\"isPartOf\":{\"@id\":\"https:\/\/rud.is\/b\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\/\/rud.is\/b\/2022\/01\/04\/starting-2022-off-with-a-fairly-complex-ggplot2-recreation-plot\/#primaryimage\"},\"image\":{\"@id\":\"https:\/\/rud.is\/b\/2022\/01\/04\/starting-2022-off-with-a-fairly-complex-ggplot2-recreation-plot\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/i0.wp.com\/rud.is\/b\/wp-content\/uploads\/2022\/01\/2022-01-04-ggplot2.jpg?fit=1428%2C1844&ssl=1\",\"datePublished\":\"2022-01-04T16:32:01+00:00\",\"breadcrumb\":{\"@id\":\"https:\/\/rud.is\/b\/2022\/01\/04\/starting-2022-off-with-a-fairly-complex-ggplot2-recreation-plot\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/rud.is\/b\/2022\/01\/04\/starting-2022-off-with-a-fairly-complex-ggplot2-recreation-plot\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/rud.is\/b\/2022\/01\/04\/starting-2022-off-with-a-fairly-complex-ggplot2-recreation-plot\/#primaryimage\",\"url\":\"https:\/\/i0.wp.com\/rud.is\/b\/wp-content\/uploads\/2022\/01\/2022-01-04-ggplot2.jpg?fit=1428%2C1844&ssl=1\",\"contentUrl\":\"https:\/\/i0.wp.com\/rud.is\/b\/wp-content\/uploads\/2022\/01\/2022-01-04-ggplot2.jpg?fit=1428%2C1844&ssl=1\",\"width\":1428,\"height\":1844,\"caption\":\"{ggplot2} recreation of NYT plot\"},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/rud.is\/b\/2022\/01\/04\/starting-2022-off-with-a-fairly-complex-ggplot2-recreation-plot\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/rud.is\/b\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Starting 2022 Off With A Fairly Complex {ggplot2} Recreation Plot\"}]},{\"@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":"Starting 2022 Off With A Fairly Complex {ggplot2} Recreation Plot - 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\/2022\/01\/04\/starting-2022-off-with-a-fairly-complex-ggplot2-recreation-plot\/","og_locale":"en_US","og_type":"article","og_title":"Starting 2022 Off With A Fairly Complex {ggplot2} Recreation Plot - rud.is","og_description":"The New York Times had a [tragic] story on Covid deaths today and one of their plots really stuck with me for how well it told that part of the story. NOTE: The red panel highlights are off a bit as I manually typed the data in (I only did the recreation to keep {ggplot2} [&hellip;]","og_url":"https:\/\/rud.is\/b\/2022\/01\/04\/starting-2022-off-with-a-fairly-complex-ggplot2-recreation-plot\/","og_site_name":"rud.is","article_published_time":"2022-01-04T16:32:01+00:00","og_image":[{"width":1428,"height":1844,"url":"https:\/\/i0.wp.com\/rud.is\/b\/wp-content\/uploads\/2022\/01\/2022-01-04-ggplot2.jpg?fit=1428%2C1844&ssl=1","type":"image\/jpeg"}],"author":"hrbrmstr","twitter_card":"summary_large_image","twitter_misc":{"Written by":"hrbrmstr","Est. reading time":"4 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/rud.is\/b\/2022\/01\/04\/starting-2022-off-with-a-fairly-complex-ggplot2-recreation-plot\/#article","isPartOf":{"@id":"https:\/\/rud.is\/b\/2022\/01\/04\/starting-2022-off-with-a-fairly-complex-ggplot2-recreation-plot\/"},"author":{"name":"hrbrmstr","@id":"https:\/\/rud.is\/b\/#\/schema\/person\/d7cb7487ab0527447f7fda5c423ff886"},"headline":"Starting 2022 Off With A Fairly Complex {ggplot2} Recreation Plot","datePublished":"2022-01-04T16:32:01+00:00","mainEntityOfPage":{"@id":"https:\/\/rud.is\/b\/2022\/01\/04\/starting-2022-off-with-a-fairly-complex-ggplot2-recreation-plot\/"},"wordCount":127,"commentCount":4,"publisher":{"@id":"https:\/\/rud.is\/b\/#\/schema\/person\/d7cb7487ab0527447f7fda5c423ff886"},"image":{"@id":"https:\/\/rud.is\/b\/2022\/01\/04\/starting-2022-off-with-a-fairly-complex-ggplot2-recreation-plot\/#primaryimage"},"thumbnailUrl":"https:\/\/i0.wp.com\/rud.is\/b\/wp-content\/uploads\/2022\/01\/2022-01-04-ggplot2.jpg?fit=1428%2C1844&ssl=1","articleSection":["ggplot","R"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/rud.is\/b\/2022\/01\/04\/starting-2022-off-with-a-fairly-complex-ggplot2-recreation-plot\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/rud.is\/b\/2022\/01\/04\/starting-2022-off-with-a-fairly-complex-ggplot2-recreation-plot\/","url":"https:\/\/rud.is\/b\/2022\/01\/04\/starting-2022-off-with-a-fairly-complex-ggplot2-recreation-plot\/","name":"Starting 2022 Off With A Fairly Complex {ggplot2} Recreation Plot - rud.is","isPartOf":{"@id":"https:\/\/rud.is\/b\/#website"},"primaryImageOfPage":{"@id":"https:\/\/rud.is\/b\/2022\/01\/04\/starting-2022-off-with-a-fairly-complex-ggplot2-recreation-plot\/#primaryimage"},"image":{"@id":"https:\/\/rud.is\/b\/2022\/01\/04\/starting-2022-off-with-a-fairly-complex-ggplot2-recreation-plot\/#primaryimage"},"thumbnailUrl":"https:\/\/i0.wp.com\/rud.is\/b\/wp-content\/uploads\/2022\/01\/2022-01-04-ggplot2.jpg?fit=1428%2C1844&ssl=1","datePublished":"2022-01-04T16:32:01+00:00","breadcrumb":{"@id":"https:\/\/rud.is\/b\/2022\/01\/04\/starting-2022-off-with-a-fairly-complex-ggplot2-recreation-plot\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/rud.is\/b\/2022\/01\/04\/starting-2022-off-with-a-fairly-complex-ggplot2-recreation-plot\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/rud.is\/b\/2022\/01\/04\/starting-2022-off-with-a-fairly-complex-ggplot2-recreation-plot\/#primaryimage","url":"https:\/\/i0.wp.com\/rud.is\/b\/wp-content\/uploads\/2022\/01\/2022-01-04-ggplot2.jpg?fit=1428%2C1844&ssl=1","contentUrl":"https:\/\/i0.wp.com\/rud.is\/b\/wp-content\/uploads\/2022\/01\/2022-01-04-ggplot2.jpg?fit=1428%2C1844&ssl=1","width":1428,"height":1844,"caption":"{ggplot2} recreation of NYT plot"},{"@type":"BreadcrumbList","@id":"https:\/\/rud.is\/b\/2022\/01\/04\/starting-2022-off-with-a-fairly-complex-ggplot2-recreation-plot\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/rud.is\/b\/"},{"@type":"ListItem","position":2,"name":"Starting 2022 Off With A Fairly Complex {ggplot2} Recreation Plot"}]},{"@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\/2022\/01\/2022-01-04-ggplot2.jpg?fit=1428%2C1844&ssl=1","jetpack_shortlink":"https:\/\/wp.me\/p23idr-3rU","jetpack_likes_enabled":true,"jetpack-related-posts":[{"id":3832,"url":"https:\/\/rud.is\/b\/2015\/12\/28\/world-map-panel-plots-with-ggplot2-2-0-ggalt\/","url_meta":{"origin":13262,"position":0},"title":"World Map Panel Plots with ggplot2 2.0 &#038; ggalt","author":"hrbrmstr","date":"2015-12-28","format":false,"excerpt":"James Austin (@awhstin) made some #spiffy 4-panel maps with base R graphics but also posited he didn't use ggplot2 because: \u2026ggplot2 and maps currently do not support world maps at this point, which does not give us a great overall view. That is certainly a box I would not put\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\/2015\/12\/facetmaps.png?fit=1154%2C722&ssl=1&resize=350%2C200","width":350,"height":200,"srcset":"https:\/\/i0.wp.com\/rud.is\/b\/wp-content\/uploads\/2015\/12\/facetmaps.png?fit=1154%2C722&ssl=1&resize=350%2C200 1x, https:\/\/i0.wp.com\/rud.is\/b\/wp-content\/uploads\/2015\/12\/facetmaps.png?fit=1154%2C722&ssl=1&resize=525%2C300 1.5x, https:\/\/i0.wp.com\/rud.is\/b\/wp-content\/uploads\/2015\/12\/facetmaps.png?fit=1154%2C722&ssl=1&resize=700%2C400 2x, https:\/\/i0.wp.com\/rud.is\/b\/wp-content\/uploads\/2015\/12\/facetmaps.png?fit=1154%2C722&ssl=1&resize=1050%2C600 3x"},"classes":[]},{"id":12282,"url":"https:\/\/rud.is\/b\/2019\/06\/06\/make-multi-point-dumbbell-plots-in-ggplot2\/","url_meta":{"origin":13262,"position":1},"title":"Make Multi-point &#8220;dumbbell&#8221; Plots in ggplot2","author":"hrbrmstr","date":"2019-06-06","format":false,"excerpt":"A user of the {ggalt} package recently posted a question about how to add points to a geom_dumbbell() plot. For now, this is not something you can do with geom_dumbbell() but with a bit of data wrangling you can do this in a pretty straightforward manner with just your data\u2026","rel":"","context":"In &quot;ggplot&quot;","block_context":{"text":"ggplot","link":"https:\/\/rud.is\/b\/category\/ggplot\/"},"img":{"alt_text":"","src":"https:\/\/i0.wp.com\/rud.is\/b\/wp-content\/uploads\/2019\/06\/there-are-three-points-2.png?fit=1200%2C560&ssl=1&resize=350%2C200","width":350,"height":200,"srcset":"https:\/\/i0.wp.com\/rud.is\/b\/wp-content\/uploads\/2019\/06\/there-are-three-points-2.png?fit=1200%2C560&ssl=1&resize=350%2C200 1x, https:\/\/i0.wp.com\/rud.is\/b\/wp-content\/uploads\/2019\/06\/there-are-three-points-2.png?fit=1200%2C560&ssl=1&resize=525%2C300 1.5x, https:\/\/i0.wp.com\/rud.is\/b\/wp-content\/uploads\/2019\/06\/there-are-three-points-2.png?fit=1200%2C560&ssl=1&resize=700%2C400 2x, https:\/\/i0.wp.com\/rud.is\/b\/wp-content\/uploads\/2019\/06\/there-are-three-points-2.png?fit=1200%2C560&ssl=1&resize=1050%2C600 3x"},"classes":[]},{"id":3649,"url":"https:\/\/rud.is\/b\/2015\/08\/27\/coloring-and-drawing-outside-the-lines-in-ggplot\/","url_meta":{"origin":13262,"position":2},"title":"Coloring (and Drawing) Outside the Lines in ggplot","author":"hrbrmstr","date":"2015-08-27","format":false,"excerpt":"Time for another Twitter-inspired blog post this week, this time from a tweet by @JonKalodimos: Is there a way to do this in #rstats #ggplot2 https:\/\/t.co\/kxWQFlYpbB\u2014 Jonathan Kalodimos (@JonKalodimos) August 27, 2015 I had seen and appreciated Ann's post on her makeover of the main graphic in [NPR's story](http:\/\/www.npr.org\/sections\/money\/2014\/10\/21\/357629765\/when-women-stopped-coding) and\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":"","width":0,"height":0},"classes":[]},{"id":13382,"url":"https:\/\/rud.is\/b\/2022\/04\/03\/turning-ggplot2-into-a-pos-point-of-sale-system\/","url_meta":{"origin":13262,"position":3},"title":"Turning {ggplot2} Into a PoS (Point-of-Sale) System","author":"hrbrmstr","date":"2022-04-03","format":false,"excerpt":"At the end of March, I caught a fleeting tweet that showcased an Epson thermal receipt printer generating a new \"ticket\" whenever a new GitHub issue was filed on a repository. @aschmelyun documents it well in this blog post. It's a pretty cool hack, self-contained on a Pi Zero. Andrew's\u2026","rel":"","context":"In &quot;R&quot;","block_context":{"text":"R","link":"https:\/\/rud.is\/b\/category\/r\/"},"img":{"alt_text":"","src":"https:\/\/i0.wp.com\/rud.is\/b\/wp-content\/uploads\/2022\/04\/FPR9RFaXwAgE6bN-scaled.jpeg?resize=350%2C200","width":350,"height":200,"srcset":"https:\/\/i0.wp.com\/rud.is\/b\/wp-content\/uploads\/2022\/04\/FPR9RFaXwAgE6bN-scaled.jpeg?resize=350%2C200 1x, https:\/\/i0.wp.com\/rud.is\/b\/wp-content\/uploads\/2022\/04\/FPR9RFaXwAgE6bN-scaled.jpeg?resize=525%2C300 1.5x, https:\/\/i0.wp.com\/rud.is\/b\/wp-content\/uploads\/2022\/04\/FPR9RFaXwAgE6bN-scaled.jpeg?resize=700%2C400 2x, https:\/\/i0.wp.com\/rud.is\/b\/wp-content\/uploads\/2022\/04\/FPR9RFaXwAgE6bN-scaled.jpeg?resize=1050%2C600 3x, https:\/\/i0.wp.com\/rud.is\/b\/wp-content\/uploads\/2022\/04\/FPR9RFaXwAgE6bN-scaled.jpeg?resize=1400%2C800 4x"},"classes":[]},{"id":4087,"url":"https:\/\/rud.is\/b\/2016\/03\/12\/ggplot2%e3%81%a7%e5%ad%97%e5%b9%95-subtitles-in-ggplot2\/","url_meta":{"origin":13262,"position":4},"title":"ggplot2\u3067\u5b57\u5e55 [Subtitles in ggplot2]","author":"hrbrmstr","date":"2016-03-12","format":false,"excerpt":"UPDATE: A newer blog post explaining the new ggplot2 additions: http:\/\/rud.is\/b\/2016\/03\/16\/supreme-annotations\/ UPDATE: this capability (+ more) are being rolled into ggplot2-proper. PR will be absorbed into ggplot2 main branch soon. exciting, annotated times ahead! UPDATE: fontsize issue has been fixed & there's a Shiny gadget available for interactively making subtitles.\u2026","rel":"","context":"In &quot;DataVis&quot;","block_context":{"text":"DataVis","link":"https:\/\/rud.is\/b\/category\/datavis-2\/"},"img":{"alt_text":"","src":"https:\/\/i0.wp.com\/rud.is\/b\/wp-content\/uploads\/2016\/03\/Fullscreen_3_12_16__7_44_PM.png?fit=1043%2C782&ssl=1&resize=350%2C200","width":350,"height":200,"srcset":"https:\/\/i0.wp.com\/rud.is\/b\/wp-content\/uploads\/2016\/03\/Fullscreen_3_12_16__7_44_PM.png?fit=1043%2C782&ssl=1&resize=350%2C200 1x, https:\/\/i0.wp.com\/rud.is\/b\/wp-content\/uploads\/2016\/03\/Fullscreen_3_12_16__7_44_PM.png?fit=1043%2C782&ssl=1&resize=525%2C300 1.5x, https:\/\/i0.wp.com\/rud.is\/b\/wp-content\/uploads\/2016\/03\/Fullscreen_3_12_16__7_44_PM.png?fit=1043%2C782&ssl=1&resize=700%2C400 2x"},"classes":[]},{"id":3243,"url":"https:\/\/rud.is\/b\/2015\/02\/01\/new-release-0-7-of-metricsgraphics-htmlwidget-grids-rollovers\/","url_meta":{"origin":13262,"position":5},"title":"New release (0.7) of metricsgraphics htmlwidget \u2014 grids &#038; rollovers","author":"hrbrmstr","date":"2015-02-01","format":false,"excerpt":"I've updated my [metricsgraphics](https:\/\/github.com\/hrbrmstr\/metricsgraphics) package to version [0.7](https:\/\/github.com\/hrbrmstr\/metricsgraphics\/releases\/tag\/v0.7). The core [MetricsGraphics](http:\/\/metricsgraphicsjs.org) JavaScript library has been updated to version 2.1.0 (from 1.1.0). Two blog-worthy features since releasing version 0.5 are `mjs_grid` (which is a `grid.arrange`-like equivalent for `metricsgraphics` plots and `mjs_add_rollover` which lets you add your own custom rollover text to\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\/13262","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=13262"}],"version-history":[{"count":0,"href":"https:\/\/rud.is\/b\/wp-json\/wp\/v2\/posts\/13262\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/rud.is\/b\/wp-json\/wp\/v2\/media\/13264"}],"wp:attachment":[{"href":"https:\/\/rud.is\/b\/wp-json\/wp\/v2\/media?parent=13262"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/rud.is\/b\/wp-json\/wp\/v2\/categories?post=13262"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/rud.is\/b\/wp-json\/wp\/v2\/tags?post=13262"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}