{"id":38,"date":"2021-07-13T20:30:54","date_gmt":"2021-07-13T20:30:54","guid":{"rendered":"https:\/\/dumdumdata.com\/?p=38"},"modified":"2021-07-13T20:41:44","modified_gmt":"2021-07-13T20:41:44","slug":"sankey-diagram-tutorial","status":"publish","type":"post","link":"https:\/\/dumdumdata.com\/index.php\/2021\/07\/13\/sankey-diagram-tutorial\/","title":{"rendered":"Sankey Diagram Tutorial"},"content":{"rendered":"\n<p>How I create a Sankey Diagram in plotly using python.<\/p>\n\n\n\n<ol class=\"wp-block-list\" type=\"1\"><li>Go to plotly and look at the examples there and realize that I\u2019m still lost.<\/li><li>Go find another example or tutorial in the public domain using a search.<\/li><li>Realize that all of them are to vague and don\u2019t describe any inner workings or assume you know something that you clearly do not.<\/li><li>Go to stack exchange and piece meal learn how to do the task<\/li><li>Write a tutorial that explains the process, start to finish.<\/li><\/ol>\n\n\n\n<p>First and Foremost!<\/p>\n\n\n\n<p>What\u2019s the question\u2026 Is the Sankey the best case for it? What is a Sankey chart anyways? Go here to learn more about <a href=\"https:\/\/mychartguide.com\/sankey-diagram\/\">Sankey Charts<\/a>.<\/p>\n\n\n\n<p>Best use cases for a Sankey diagram:<\/p>\n\n\n\n<ol class=\"wp-block-list\" type=\"1\"><li>You have a flow process that you want to present in a simple manner.<\/li><li>You have data you want to show proportionally in a way that doesn\u2019t involve showing hard numbers.<\/li><li>You have a supervisor who just really likes overly complicated and colorful graphs that are impossible to read (what happens when it is used poorly).<\/li><\/ol>\n\n\n\n<p>My question is \u201cHow many of my department\u2019s cases are legit and how many are dismissed?\u201d So, it has a direction where cases move into a status of some sort. Also it has more than one starting point. For this article, I&#8217;m just going to cover the basics of the Sankey.<\/p>\n\n\n\n<p>Now, can you use Sankey if you have only one starting point? Sure, when you have 2 or three steps, it can be a really good way to show how things move into and out various stages. But when you have one starting step and only one step out, you\u2019ve just made a pie chart. Sankey charts are great for non-technical audiences interested in big pictures and process flows.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code># import all required libraries\nimport numpy as np\nimport plotly\nimport plotly.graph_objects as go\n\n#Basic example of a sankey diagram from Geeks for Geeks\nfig = go.Figure(data=&#91;go.Sankey(\n    node = dict(\n      thickness = 5,\n      line = dict(color = \"green\", width = 0.1),\n      label = &#91;\"Issue A\", \"Issue B\", \"C\", \"D\", \"E\", \"F\"],\n      color = \"blue\"\n    ),\n    link = dict(\n          \n      # indices correspond to labels\n      source = &#91;0, 6, 1, 4, 2, 3], \n      target = &#91;2, 1, 5, 2, 1, 5],\n      value = &#91;7, 1, 3, 6, 9, 4]\n  ))])\n  \nfig.show()\n<\/code><\/pre>\n\n\n\n<hr class=\"wp-block-separator is-style-wide\"\/>\n\n\n\n<p class=\"has-vivid-red-color has-text-color has-large-font-size\">STOP!<\/p>\n\n\n\n<p>Which plotly are you using? Yup, there\u2019s free and then there\u2019s the fancy. I\u2019m using the free one which is \u201cplotly.graph_objects\u201d<\/p>\n\n\n\n<p>Moving on from here, we can see the first block of code produces a diagram like this.<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"615\" height=\"290\" src=\"https:\/\/dumdumdata.com\/wp-content\/uploads\/2021\/07\/Sankey1.png\" alt=\"\" class=\"wp-image-42\" srcset=\"https:\/\/dumdumdata.com\/wp-content\/uploads\/2021\/07\/Sankey1.png 615w, https:\/\/dumdumdata.com\/wp-content\/uploads\/2021\/07\/Sankey1-300x141.png 300w\" sizes=\"auto, (max-width: 615px) 100vw, 615px\" \/><figcaption>A basic Sankey diagram containing a link in grey and a node in blue.<\/figcaption><\/figure>\n\n\n\n<hr class=\"wp-block-separator is-style-wide\"\/>\n\n\n\n<p>Let&#8217;s edit the code a little so we can better understand what the code is actually doing.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>fig = go.Figure(data=&#91;go.Sankey(\n    node = dict(\n      thickness = 5,\n      line = dict(color = \"orange\", width = 0.5),\n      label = &#91;\"Intake\", \"Holding\", \"Experiment 1\", \"Experiment 2\", \"Pass\", \"Out-Process\", \u201c\u201d],\n      color = \"pink\"\n    ),\n    link = dict(\n          \n      # indices correspond to labels\n      source = &#91;0, 1, 2, 3, 4, 5], \n      target = &#91;1, 2, 3, 4, 5, 6],\n      value = &#91;1, 1, 1, 1, 1, 1]\n  ))])\n  \nfig.show()\n<\/code><\/pre>\n\n\n\n<p>Giving us this output:<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"670\" height=\"247\" src=\"https:\/\/dumdumdata.com\/wp-content\/uploads\/2021\/07\/sankey2.png\" alt=\"\" class=\"wp-image-45\" srcset=\"https:\/\/dumdumdata.com\/wp-content\/uploads\/2021\/07\/sankey2.png 670w, https:\/\/dumdumdata.com\/wp-content\/uploads\/2021\/07\/sankey2-300x111.png 300w\" sizes=\"auto, (max-width: 670px) 100vw, 670px\" \/><figcaption>We&#8217;ve made a straight path here where each node is the same coming in and out. Note that the last node is not labled.<\/figcaption><\/figure>\n\n\n\n<pre class=\"wp-block-code\"><code>label = &#91;\"Intake\", \"Holding\", \"Experiment 1\", \"Experiment 2\", \"Pass\", \"Out-Process\", \u201c\u201d ]\nlabel = &#91;0 , 1, 2 , 3 , 4, 5 , \u201c\u201d]<\/code><\/pre>\n\n\n\n<hr class=\"wp-block-separator is-style-wide\"\/>\n\n\n\n<p>Notice that all the source and target values are in order (where the <em>source<\/em> is <em>target<\/em>-1). We can correlate this to the labels in the node.<\/p>\n\n\n\n<p>At this point, you may wonder about the value \u201c6\u201d in the <em>target<\/em> list. Well, plugging any number higher than the max length of the list will result in a straight line. The number 6, 99, or 10987 all result in the same output (our straight bar). In my case, the last position of the labels list is just an empty string.<\/p>\n\n\n\n<p>If we use any value equal to or less than the length of the labels list we end up with a diagram that curls back into itself.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>source = &#91;0, 1, 2, 3, 4, 5],\ntarget = &#91;1, 2, 3, 4, 5, 5],\nvalue = &#91;1, 1, 1, 1, 1, 1]\n<\/code><\/pre>\n\n\n\n<p>What we get with the values listed above.<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"624\" height=\"283\" src=\"https:\/\/dumdumdata.com\/wp-content\/uploads\/2021\/07\/sankey3-1.png\" alt=\"\" class=\"wp-image-46\" srcset=\"https:\/\/dumdumdata.com\/wp-content\/uploads\/2021\/07\/sankey3-1.png 624w, https:\/\/dumdumdata.com\/wp-content\/uploads\/2021\/07\/sankey3-1-300x136.png 300w\" sizes=\"auto, (max-width: 624px) 100vw, 624px\" \/><figcaption>The linear Sankey now has a cool little wheel on the end.<\/figcaption><\/figure>\n\n\n\n<hr class=\"wp-block-separator is-style-wide\"\/>\n\n\n\n<p>If we use the following values we end up with a more funnel shaped diagram.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>source = &#91;0, 1, 2, 3, 4, 5], \ntarget = &#91;1, 2, 3, 4, 5, 6],\nvalue = &#91;2**0, 2**1, 2**2, 2**4, 2**5, 2**6]<\/code><\/pre>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"624\" height=\"243\" src=\"https:\/\/dumdumdata.com\/wp-content\/uploads\/2021\/07\/sankey4.png\" alt=\"\" class=\"wp-image-47\" srcset=\"https:\/\/dumdumdata.com\/wp-content\/uploads\/2021\/07\/sankey4.png 624w, https:\/\/dumdumdata.com\/wp-content\/uploads\/2021\/07\/sankey4-300x117.png 300w\" sizes=\"auto, (max-width: 624px) 100vw, 624px\" \/><figcaption>Changing the values in the <em>values<\/em> list results in the width of the bars changing. In this case each step is squared.<\/figcaption><\/figure>\n\n\n\n<hr class=\"wp-block-separator is-style-wide\"\/>\n\n\n\n<p>It\u2019s important to note that the values in the <em>values<\/em> list have no bearing on each other. They do not have to add up in any way or correlate in any other way.<\/p>\n\n\n\n<p>All the above are some sort of \u201cfunnel\u201d graph made with the Sankey diagram. To really use the Sankey, we want to have various stages at different places.<\/p>\n\n\n\n<p>So let\u2019s have 5 pretend people going through my imaginary study. In this study, different subjects are either subjected to experiment 1, experiment 2 or both, and then do an out-process task with the experimenter all on different dates. If a subject leaves the study early, declines, or fails to return then they are described as a \u201cDrop.\u201d<\/p>\n\n\n\n<figure class=\"wp-block-table\"><table><thead><tr><td><strong>Person<\/strong><\/td><td><strong>Step 1<\/strong><\/td><td><strong>Step 2<\/strong><\/td><td><strong>Step 3<\/strong><\/td><td><strong>Step 4<\/strong><\/td><\/tr><\/thead><tbody><tr><td>Person A<\/td><td>Intake<\/td><td>Holding<\/td><td>Drop (step3)<\/td><td>&#8212;<\/td><\/tr><tr><td>Person B<\/td><td>Intake<\/td><td>Experiment 1<\/td><td>Pass<\/td><td>Out-Process<\/td><\/tr><tr><td>Person C<\/td><td>Intake<\/td><td>Experiment 1<\/td><td>Experiment 2<\/td><td>Out-Process<\/td><\/tr><tr><td>Person D<\/td><td>Intake<\/td><td>Holding<\/td><td>Experiment 2<\/td><td>Out-Process<\/td><\/tr><tr><td>Person E<\/td><td>Intake<\/td><td>Experiment 1<\/td><td>Experiment 2<\/td><td>Drop (step4)<\/td><\/tr><\/tbody><\/table><figcaption>Example of a repeated measures experiment with outcomes for each subject and what conditions they were subjected to.<\/figcaption><\/figure>\n\n\n\n<p>I\u2019ve added a potential stage called the \u201cDrop\u201d stage that indicates that someone left the study early.<\/p>\n\n\n\n<p>To translate to this use for the Sankey diagram, it helps me to draw\/write it out.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>label = &#91;\"Intake\", \"Holding\", \"Experiment 1\", \"Experiment 2\", \u201cDrop1\u201d,  \"Pass\", \"Out-Process\", \u201cDrop2\u201d ]\nlabel = &#91;0, 1 , 2, 3, 4, 5, 6, 7]<\/code><\/pre>\n\n\n\n<p>Recall:<\/p>\n\n\n\n<p>[0] Intake to [1] Holding = 2 people<\/p>\n\n\n\n<p>[0] Intake to [2] Experiment 1 = 3 people<\/p>\n\n\n\n<p>[1] Holding to [3] Experiment 2 = 1 Person<\/p>\n\n\n\n<p>[1] Holding to [4] Drop1 = 1 Person<\/p>\n\n\n\n<p>[2] Experiment 1 to [3] Experiment 2 = 2 people<\/p>\n\n\n\n<p>[2] Experiment 1 to [5] Pass = 1 Person<\/p>\n\n\n\n<p>[3] Experiment 2 to [6] Out-Process = 2 People<\/p>\n\n\n\n<p>[3] Experiment 2 to [7] Drop2 = 1 Person<\/p>\n\n\n\n<p>[5] Pass to [6] Out-Process = 1 Person<\/p>\n\n\n\n<p><strong>This creates the following lists:<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>Text Box: source =&#91;0,0,1,1,2,2,3,3,5], \ntarget =&#91;1,2,3,4,3,5,6,7,6],\nvalue =&#91;2,3,1,1,2,1,2,1,1],<\/code><\/pre>\n\n\n\n<p><strong>Which outputs the following:<\/strong><\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"624\" height=\"250\" src=\"https:\/\/dumdumdata.com\/wp-content\/uploads\/2021\/07\/sankey5.png\" alt=\"\" class=\"wp-image-48\" srcset=\"https:\/\/dumdumdata.com\/wp-content\/uploads\/2021\/07\/sankey5.png 624w, https:\/\/dumdumdata.com\/wp-content\/uploads\/2021\/07\/sankey5-300x120.png 300w\" sizes=\"auto, (max-width: 624px) 100vw, 624px\" \/><figcaption>Sankey diagram showing the movement of participants through trials and endings.<\/figcaption><\/figure>\n\n\n\n<p>To change the colors of the links or nodes we can pass a list of colors to the link and node dictionaries.<\/p>\n\n\n\n<hr class=\"wp-block-separator is-style-wide\"\/>\n\n\n\n<p>Can we make this look any more distinct?<\/p>\n\n\n\n<p>Yes, plotly will allow us to pass a list of colors that annotate stages.<\/p>\n\n\n\n<hr class=\"wp-block-separator is-style-wide\"\/>\n\n\n\n<p>Input:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>#should have the same number of colors named as the links (the length of the values list) and in that order\ncolor_link = &#91;'lightcoral', 'red', 'lemonchiffon', 'palegreen', 'yellow', 'lightskyblue', 'thistle', 'violet', 'lightpink']\n\n#color node follows the order of your labels\ncolor_node = &#91;'pink', 'blue', 'green', 'green', 'orange', 'yellow', 'brown', 'orange'] \n\n\n\n#Basic example of a sankey diagram from Geeks for Geeks\nfig = go.Figure(data=&#91;go.Sankey(\n    node = dict(\n        thickness = 20,\n        pad = 100,\n        line = dict(color = 'black', width = 0.5),\n        label = &#91;\"Intake\", \"Holding\", \"Experiment 1\", \"Experiment 2\", \"Drop1\", \"Pass\", \"Out-Process\", \"Drop2\"],\n        color = color_node\n    ),\n    link = dict(\n          \n      # indices correspond to labels\n      source = &#91;0,0,1,1,2,2,3,3,5], \n      target = &#91;1,2,3,4,3,5,6,7,6],\n      value =  &#91;2,3,1,1,2,1,2,1,1],\n        color = color_link\n  ))])\n  \nfig.show()\n<\/code><\/pre>\n\n\n\n<p>Output:<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"624\" height=\"235\" src=\"https:\/\/dumdumdata.com\/wp-content\/uploads\/2021\/07\/sankey6.png\" alt=\"\" class=\"wp-image-49\" srcset=\"https:\/\/dumdumdata.com\/wp-content\/uploads\/2021\/07\/sankey6.png 624w, https:\/\/dumdumdata.com\/wp-content\/uploads\/2021\/07\/sankey6-300x113.png 300w\" sizes=\"auto, (max-width: 624px) 100vw, 624px\" \/><\/figure>\n\n\n\n<p>And that&#8217;s all I have for now guys.<\/p>\n\n\n\n<p><\/p>\n","protected":false},"excerpt":{"rendered":"<p>How I create a Sankey Diagram in plotly using python. Go to plotly and look at the examples there and realize that I\u2019m still lost. Go find another example or tutorial in the public domain using a search. Realize that all of them are to vague and don\u2019t describe any inner workings or assume you [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-38","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v18.4.1 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>Sankey Diagram Tutorial - DumDum Data<\/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:\/\/dumdumdata.com\/index.php\/2021\/07\/13\/sankey-diagram-tutorial\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Sankey Diagram Tutorial - DumDum Data\" \/>\n<meta property=\"og:description\" content=\"How I create a Sankey Diagram in plotly using python. Go to plotly and look at the examples there and realize that I\u2019m still lost. Go find another example or tutorial in the public domain using a search. Realize that all of them are to vague and don\u2019t describe any inner workings or assume you [&hellip;]\" \/>\n<meta property=\"og:url\" content=\"https:\/\/dumdumdata.com\/index.php\/2021\/07\/13\/sankey-diagram-tutorial\/\" \/>\n<meta property=\"og:site_name\" content=\"DumDum Data\" \/>\n<meta property=\"article:published_time\" content=\"2021-07-13T20:30:54+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2021-07-13T20:41:44+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/dumdumdata.com\/wp-content\/uploads\/2021\/07\/Sankey1.png\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Jessica Faulk\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"5 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebSite\",\"@id\":\"https:\/\/dumdumdata.com\/#website\",\"url\":\"https:\/\/dumdumdata.com\/\",\"name\":\"DumDum Data\",\"description\":\"Dumb Data, Smart People\",\"publisher\":{\"@id\":\"https:\/\/dumdumdata.com\/#\/schema\/person\/423acddeb2f237b43cc8f8bbc552634e\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/dumdumdata.com\/?s={search_term_string}\"},\"query-input\":\"required name=search_term_string\"}],\"inLanguage\":\"en-US\"},{\"@type\":\"ImageObject\",\"@id\":\"https:\/\/dumdumdata.com\/index.php\/2021\/07\/13\/sankey-diagram-tutorial\/#primaryimage\",\"inLanguage\":\"en-US\",\"url\":\"https:\/\/dumdumdata.com\/wp-content\/uploads\/2021\/07\/Sankey1.png\",\"contentUrl\":\"https:\/\/dumdumdata.com\/wp-content\/uploads\/2021\/07\/Sankey1.png\",\"width\":615,\"height\":290},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/dumdumdata.com\/index.php\/2021\/07\/13\/sankey-diagram-tutorial\/#webpage\",\"url\":\"https:\/\/dumdumdata.com\/index.php\/2021\/07\/13\/sankey-diagram-tutorial\/\",\"name\":\"Sankey Diagram Tutorial - DumDum Data\",\"isPartOf\":{\"@id\":\"https:\/\/dumdumdata.com\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\/\/dumdumdata.com\/index.php\/2021\/07\/13\/sankey-diagram-tutorial\/#primaryimage\"},\"datePublished\":\"2021-07-13T20:30:54+00:00\",\"dateModified\":\"2021-07-13T20:41:44+00:00\",\"breadcrumb\":{\"@id\":\"https:\/\/dumdumdata.com\/index.php\/2021\/07\/13\/sankey-diagram-tutorial\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/dumdumdata.com\/index.php\/2021\/07\/13\/sankey-diagram-tutorial\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/dumdumdata.com\/index.php\/2021\/07\/13\/sankey-diagram-tutorial\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/dumdumdata.com\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Sankey Diagram Tutorial\"}]},{\"@type\":\"Article\",\"@id\":\"https:\/\/dumdumdata.com\/index.php\/2021\/07\/13\/sankey-diagram-tutorial\/#article\",\"isPartOf\":{\"@id\":\"https:\/\/dumdumdata.com\/index.php\/2021\/07\/13\/sankey-diagram-tutorial\/#webpage\"},\"author\":{\"@id\":\"https:\/\/dumdumdata.com\/#\/schema\/person\/423acddeb2f237b43cc8f8bbc552634e\"},\"headline\":\"Sankey Diagram Tutorial\",\"datePublished\":\"2021-07-13T20:30:54+00:00\",\"dateModified\":\"2021-07-13T20:41:44+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/dumdumdata.com\/index.php\/2021\/07\/13\/sankey-diagram-tutorial\/#webpage\"},\"wordCount\":875,\"commentCount\":0,\"publisher\":{\"@id\":\"https:\/\/dumdumdata.com\/#\/schema\/person\/423acddeb2f237b43cc8f8bbc552634e\"},\"image\":{\"@id\":\"https:\/\/dumdumdata.com\/index.php\/2021\/07\/13\/sankey-diagram-tutorial\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/dumdumdata.com\/wp-content\/uploads\/2021\/07\/Sankey1.png\",\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\/\/dumdumdata.com\/index.php\/2021\/07\/13\/sankey-diagram-tutorial\/#respond\"]}]},{\"@type\":[\"Person\",\"Organization\"],\"@id\":\"https:\/\/dumdumdata.com\/#\/schema\/person\/423acddeb2f237b43cc8f8bbc552634e\",\"name\":\"Jessica Faulk\",\"image\":{\"@type\":\"ImageObject\",\"@id\":\"https:\/\/dumdumdata.com\/#personlogo\",\"inLanguage\":\"en-US\",\"url\":\"https:\/\/dumdumdata.com\/wp-content\/uploads\/2021\/05\/article-2309306-194D4FF9000005DC-692_634x414.jpg\",\"contentUrl\":\"https:\/\/dumdumdata.com\/wp-content\/uploads\/2021\/05\/article-2309306-194D4FF9000005DC-692_634x414.jpg\",\"width\":634,\"height\":414,\"caption\":\"Jessica Faulk\"},\"logo\":{\"@id\":\"https:\/\/dumdumdata.com\/#personlogo\"},\"sameAs\":[\"https:\/\/dumdumdata.com\",\"https:\/\/www.linkedin.com\/in\/jessicalfaulk\/\"],\"url\":\"https:\/\/dumdumdata.com\/index.php\/author\/jessfaulk\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Sankey Diagram Tutorial - DumDum Data","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:\/\/dumdumdata.com\/index.php\/2021\/07\/13\/sankey-diagram-tutorial\/","og_locale":"en_US","og_type":"article","og_title":"Sankey Diagram Tutorial - DumDum Data","og_description":"How I create a Sankey Diagram in plotly using python. Go to plotly and look at the examples there and realize that I\u2019m still lost. Go find another example or tutorial in the public domain using a search. Realize that all of them are to vague and don\u2019t describe any inner workings or assume you [&hellip;]","og_url":"https:\/\/dumdumdata.com\/index.php\/2021\/07\/13\/sankey-diagram-tutorial\/","og_site_name":"DumDum Data","article_published_time":"2021-07-13T20:30:54+00:00","article_modified_time":"2021-07-13T20:41:44+00:00","og_image":[{"url":"https:\/\/dumdumdata.com\/wp-content\/uploads\/2021\/07\/Sankey1.png"}],"twitter_card":"summary_large_image","twitter_misc":{"Written by":"Jessica Faulk","Est. reading time":"5 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebSite","@id":"https:\/\/dumdumdata.com\/#website","url":"https:\/\/dumdumdata.com\/","name":"DumDum Data","description":"Dumb Data, Smart People","publisher":{"@id":"https:\/\/dumdumdata.com\/#\/schema\/person\/423acddeb2f237b43cc8f8bbc552634e"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/dumdumdata.com\/?s={search_term_string}"},"query-input":"required name=search_term_string"}],"inLanguage":"en-US"},{"@type":"ImageObject","@id":"https:\/\/dumdumdata.com\/index.php\/2021\/07\/13\/sankey-diagram-tutorial\/#primaryimage","inLanguage":"en-US","url":"https:\/\/dumdumdata.com\/wp-content\/uploads\/2021\/07\/Sankey1.png","contentUrl":"https:\/\/dumdumdata.com\/wp-content\/uploads\/2021\/07\/Sankey1.png","width":615,"height":290},{"@type":"WebPage","@id":"https:\/\/dumdumdata.com\/index.php\/2021\/07\/13\/sankey-diagram-tutorial\/#webpage","url":"https:\/\/dumdumdata.com\/index.php\/2021\/07\/13\/sankey-diagram-tutorial\/","name":"Sankey Diagram Tutorial - DumDum Data","isPartOf":{"@id":"https:\/\/dumdumdata.com\/#website"},"primaryImageOfPage":{"@id":"https:\/\/dumdumdata.com\/index.php\/2021\/07\/13\/sankey-diagram-tutorial\/#primaryimage"},"datePublished":"2021-07-13T20:30:54+00:00","dateModified":"2021-07-13T20:41:44+00:00","breadcrumb":{"@id":"https:\/\/dumdumdata.com\/index.php\/2021\/07\/13\/sankey-diagram-tutorial\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/dumdumdata.com\/index.php\/2021\/07\/13\/sankey-diagram-tutorial\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/dumdumdata.com\/index.php\/2021\/07\/13\/sankey-diagram-tutorial\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/dumdumdata.com\/"},{"@type":"ListItem","position":2,"name":"Sankey Diagram Tutorial"}]},{"@type":"Article","@id":"https:\/\/dumdumdata.com\/index.php\/2021\/07\/13\/sankey-diagram-tutorial\/#article","isPartOf":{"@id":"https:\/\/dumdumdata.com\/index.php\/2021\/07\/13\/sankey-diagram-tutorial\/#webpage"},"author":{"@id":"https:\/\/dumdumdata.com\/#\/schema\/person\/423acddeb2f237b43cc8f8bbc552634e"},"headline":"Sankey Diagram Tutorial","datePublished":"2021-07-13T20:30:54+00:00","dateModified":"2021-07-13T20:41:44+00:00","mainEntityOfPage":{"@id":"https:\/\/dumdumdata.com\/index.php\/2021\/07\/13\/sankey-diagram-tutorial\/#webpage"},"wordCount":875,"commentCount":0,"publisher":{"@id":"https:\/\/dumdumdata.com\/#\/schema\/person\/423acddeb2f237b43cc8f8bbc552634e"},"image":{"@id":"https:\/\/dumdumdata.com\/index.php\/2021\/07\/13\/sankey-diagram-tutorial\/#primaryimage"},"thumbnailUrl":"https:\/\/dumdumdata.com\/wp-content\/uploads\/2021\/07\/Sankey1.png","inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/dumdumdata.com\/index.php\/2021\/07\/13\/sankey-diagram-tutorial\/#respond"]}]},{"@type":["Person","Organization"],"@id":"https:\/\/dumdumdata.com\/#\/schema\/person\/423acddeb2f237b43cc8f8bbc552634e","name":"Jessica Faulk","image":{"@type":"ImageObject","@id":"https:\/\/dumdumdata.com\/#personlogo","inLanguage":"en-US","url":"https:\/\/dumdumdata.com\/wp-content\/uploads\/2021\/05\/article-2309306-194D4FF9000005DC-692_634x414.jpg","contentUrl":"https:\/\/dumdumdata.com\/wp-content\/uploads\/2021\/05\/article-2309306-194D4FF9000005DC-692_634x414.jpg","width":634,"height":414,"caption":"Jessica Faulk"},"logo":{"@id":"https:\/\/dumdumdata.com\/#personlogo"},"sameAs":["https:\/\/dumdumdata.com","https:\/\/www.linkedin.com\/in\/jessicalfaulk\/"],"url":"https:\/\/dumdumdata.com\/index.php\/author\/jessfaulk\/"}]}},"_links":{"self":[{"href":"https:\/\/dumdumdata.com\/index.php\/wp-json\/wp\/v2\/posts\/38","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/dumdumdata.com\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/dumdumdata.com\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/dumdumdata.com\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/dumdumdata.com\/index.php\/wp-json\/wp\/v2\/comments?post=38"}],"version-history":[{"count":5,"href":"https:\/\/dumdumdata.com\/index.php\/wp-json\/wp\/v2\/posts\/38\/revisions"}],"predecessor-version":[{"id":53,"href":"https:\/\/dumdumdata.com\/index.php\/wp-json\/wp\/v2\/posts\/38\/revisions\/53"}],"wp:attachment":[{"href":"https:\/\/dumdumdata.com\/index.php\/wp-json\/wp\/v2\/media?parent=38"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/dumdumdata.com\/index.php\/wp-json\/wp\/v2\/categories?post=38"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/dumdumdata.com\/index.php\/wp-json\/wp\/v2\/tags?post=38"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}