{"id":261,"date":"2018-07-24T12:59:50","date_gmt":"2018-07-24T16:59:50","guid":{"rendered":"http:\/\/blog.uvm.edu\/tbplante\/?p=261"},"modified":"2020-09-16T09:27:10","modified_gmt":"2020-09-16T13:27:10","slug":"rendering-xkcd-2023-misleading-graph-makers-in-stata","status":"publish","type":"post","link":"https:\/\/blog.uvm.edu\/tbplante\/2018\/07\/24\/rendering-xkcd-2023-misleading-graph-makers-in-stata\/","title":{"rendered":"Rendering XKCD #2023 &#8220;Misleading Graph Makers&#8221; in Stata"},"content":{"rendered":"\n<h2 class=\"wp-block-heading\">Let&#8217;s render an XKCD comic using Stata!<\/h2>\n\n\n\n<p>I loved today&#8217;s <a href=\"https:\/\/xkcd.com\/2023\/\">XKCD comic<\/a> so I decided to take some time while eating my sandwich to write a .do file script to render it in Stata. There aren&#8217;t great smooth line options without figuring out the exact function for each line in Stata, so I approximated the data points. One interesting problem was including quotes in the X axis label since quotation marks are used to define the label and line breaks for labels. The <a href=\"https:\/\/www.stata.com\/statalist\/archive\/2004-07\/msg00463.html\">solution<\/a> was wrapping the line with an opening tick (`, to the left of number 1 on your keyboard) and closing with an apostrophe. This is also a nice example of how to input data in a .do file.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">End result:<\/h2>\n\n\n\n<div class=\"wp-block-media-text alignwide is-stacked-on-mobile\" style=\"grid-template-columns:85% auto\"><figure class=\"wp-block-media-text__media\"><img loading=\"lazy\" decoding=\"async\" width=\"1000\" height=\"727\" src=\"http:\/\/blog.uvm.edu\/tbplante\/files\/2018\/07\/xkcd_2023.png\" alt=\"\" class=\"wp-image-262\" srcset=\"https:\/\/blog.uvm.edu\/tbplante\/files\/2018\/07\/xkcd_2023.png 1000w, https:\/\/blog.uvm.edu\/tbplante\/files\/2018\/07\/xkcd_2023-300x218.png 300w, https:\/\/blog.uvm.edu\/tbplante\/files\/2018\/07\/xkcd_2023-768x558.png 768w\" sizes=\"auto, (max-width: 1000px) 100vw, 1000px\" \/><\/figure><div class=\"wp-block-media-text__content\">\n<p class=\"has-large-font-size\"><\/p>\n<\/div><\/div>\n\n\n\n<h2 class=\"wp-block-heading\">Code follows.<\/h2>\n\n\n<pre>clear all\n\ninput id proportion band1 band2 band3 band4 band5 band6 band7 band8 band9 band10\nid proportion band1 band2 band3 band4 band5 band6 band7 band8 band9 band10\n0 . 21 22 23 24 25 26 27 28 29 30\n0.3 . 21 22 23.7 25.5 26.3 28 28.8 29.2 29.5 30\n0.5 . 20.8 22.5 24.7 27 28 29 29.2 29.4 29.7 30\n0.7 . 20.6 25 27.4 28.4 29 29.3 29.5 29.6 29.9 30\n0.9 . 20.1 28 28.5 29 29.3 29.5 29.7 29.8 29.9 30\n1 23 20.1 28.5 29 29.3 29.5 29.6 29.7 29.8 29.9 30\n1.3 . 20.1 29.2 29.3 29.4 29.5 29.6 29.7 29.8 29.9 30\n2 23.5 20.1 29.2 29.3 29.4 29.5 29.6 29.7 29.8 29.9 30\n3 22.3 20.1 29.2 29.3 29.4 29.5 29.6 29.7 29.8 29.9 30\n4 23.5 20.1 29.2 29.3 29.4 29.5 29.6 29.7 29.8 29.9 30\n5 23 20.1 29.2 29.3 29.4 29.5 29.6 29.7 29.8 29.9 30\n6 28 20.1 29.2 29.3 29.4 29.5 29.6 29.7 29.8 29.9 30\nend\n\nset scheme s1mono\n\ngraph twoway \/\/\/\n(connected proportion id, lcolor(gs0) mcolor(gs0)) \/\/\/\n(scatter band1 id, conn(j) lstyle(solid) lcolor(gs12) mstyle(none)) \/\/\/\n(scatter band2 id, conn(j) lstyle(solid) lcolor(gs12) mstyle(none)) \/\/\/\n(scatter band3 id, conn(j) lstyle(solid) lcolor(gs12) mstyle(none)) \/\/\/\n(scatter band4 id, conn(j) lstyle(solid) lcolor(gs12) mstyle(none)) \/\/\/\n(scatter band5 id, conn(j) lstyle(solid) lcolor(gs12) mstyle(none)) \/\/\/\n(scatter band6 id, conn(j) lstyle(solid) lcolor(gs12) mstyle(none)) \/\/\/\n(scatter band7 id, conn(j) lstyle(solid) lcolor(gs12) mstyle(none)) \/\/\/\n(scatter band8 id, conn(j) lstyle(solid) lcolor(gs12) mstyle(none)) \/\/\/\n(scatter band9 id, conn(j) lstyle(solid) lcolor(gs12) mstyle(none)) \/\/\/\n(scatter band10 id, conn(j) lstyle(solid) lcolor(gs12) mstyle(none)) \/\/\/\n, \/\/\/\ntitle(Y-Axis) \/\/\/\nxlabel(none) \/\/\/ \nxline(1(1)6, lpattern(solid) lcolor(gs12)) \/\/\/\nylabel(20 \"0%\" 25 \"50%\" 30 \"100%\", angle(0)) \/\/\/\naspect(1) \/\/\/\nytitle(\"\") \/\/\/\nlegend(off) \/\/\/\nxtitle(`\"People have wised up to the \"carefully\"' \/\/\/\n`\"chosen Y-axis range\" trick, so we misleading\"' \/\/\/\n\"graph makers have had to get creative.\")\n\ngraph export xkcd_2023.png, width(1000) replace<\/pre>","protected":false},"excerpt":{"rendered":"<p>Let&#8217;s render an XKCD comic using Stata! I loved today&#8217;s XKCD comic so I decided to take some time while eating my sandwich to write a .do file script to render it in Stata. There aren&#8217;t great smooth line options without figuring out the exact function for each line in Stata, so I approximated the &hellip; <a href=\"https:\/\/blog.uvm.edu\/tbplante\/2018\/07\/24\/rendering-xkcd-2023-misleading-graph-makers-in-stata\/\" class=\"more-link\">Continue reading <span class=\"screen-reader-text\">Rendering XKCD #2023 &#8220;Misleading Graph Makers&#8221; in Stata<\/span><\/a><\/p>\n","protected":false},"author":4473,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[477491],"tags":[],"class_list":["post-261","post","type-post","status-publish","format-standard","hentry","category-stata-code"],"_links":{"self":[{"href":"https:\/\/blog.uvm.edu\/tbplante\/wp-json\/wp\/v2\/posts\/261","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/blog.uvm.edu\/tbplante\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blog.uvm.edu\/tbplante\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blog.uvm.edu\/tbplante\/wp-json\/wp\/v2\/users\/4473"}],"replies":[{"embeddable":true,"href":"https:\/\/blog.uvm.edu\/tbplante\/wp-json\/wp\/v2\/comments?post=261"}],"version-history":[{"count":4,"href":"https:\/\/blog.uvm.edu\/tbplante\/wp-json\/wp\/v2\/posts\/261\/revisions"}],"predecessor-version":[{"id":568,"href":"https:\/\/blog.uvm.edu\/tbplante\/wp-json\/wp\/v2\/posts\/261\/revisions\/568"}],"wp:attachment":[{"href":"https:\/\/blog.uvm.edu\/tbplante\/wp-json\/wp\/v2\/media?parent=261"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blog.uvm.edu\/tbplante\/wp-json\/wp\/v2\/categories?post=261"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blog.uvm.edu\/tbplante\/wp-json\/wp\/v2\/tags?post=261"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}