{"componentChunkName":"component---src-templates-work-js","path":"/works/how-to-make-a-countplot-in-seaborn-plotly-and-matplotlib","result":{"data":{"datoCmsWork":{"seoMetaTags":{"tags":[{"tagName":"title","content":"How to make a \"countplot\" in seaborn, plotly and matplotlib"},{"tagName":"meta","attributes":{"property":"og:title","content":"How to make a \"countplot\" in seaborn, plotly and matplotlib"}},{"tagName":"meta","attributes":{"name":"twitter:title","content":"How to make a \"countplot\" in seaborn, plotly and matplotlib"}},{"tagName":"meta","attributes":{"name":"description","content":"Pitch founders hackathon business-to-business growth hacking pivot rockstar deployment business model canvas handshake stock business-to-consumer. "}},{"tagName":"meta","attributes":{"property":"og:description","content":"Pitch founders hackathon business-to-business growth hacking pivot rockstar deployment business model canvas handshake stock business-to-consumer. "}},{"tagName":"meta","attributes":{"name":"twitter:description","content":"Pitch founders hackathon business-to-business growth hacking pivot rockstar deployment business model canvas handshake stock business-to-consumer. "}},{"tagName":"meta","attributes":{"name":"twitter:site","content":"@xxx"}},{"tagName":"meta","attributes":{"name":"twitter:card","content":"summary"}},{"tagName":"meta","attributes":{"property":"article:modified_time","content":"2020-11-06T11:39:55Z"}},{"tagName":"meta","attributes":{"property":"article:published_time","content":"2020-11-06T10:54:09Z"}},{"tagName":"meta","attributes":{"property":"article:publisher","content":"https://www.facebook.com/xxx"}},{"tagName":"meta","attributes":{"property":"og:locale","content":"en_EN"}},{"tagName":"meta","attributes":{"property":"og:type","content":"article"}},{"tagName":"meta","attributes":{"property":"og:site_name","content":"Fred Lich"}},{"tagName":"meta","attributes":{"property":"og:image","content":"https://www.datocms-assets.com/28985/1590861119-favicon.png?w=1000&fit=max&fm=jpg"}},{"tagName":"meta","attributes":{"name":"twitter:image","content":"https://www.datocms-assets.com/28985/1590861119-favicon.png?w=1000&fit=max&fm=jpg"}}]},"title":"How to make a \"countplot\" in seaborn, plotly and matplotlib","excerpt":"I find myself often needing to make a 'countplot'...","gallery":[],"descriptionNode":{"childMarkdownRemark":{"html":"<h1>How to make a countplot</h1>\n<p>I find myself often needing to make a 'countplot'. I.e. a histogram of the counts of values of a particular field. Here's how to do it using different libraries. Sometimes you want quick, sometimes pretty, sometimes interactive.</p>\n<p>Assume you dataframe is stored in <code>df</code>. And the column you are interested in is <code>result</code></p>\n<p>Combine with <a href=\"/works/jupyter-notebook-matplotlib-settings\">retina jupyter matplotlib settings</a> for prettier output.</p>\n<h2>In matplotlib</h2>\n<pre><code class=\"language-python\">df.result.plot.hist(bins=50)\n</code></pre>\n<h2>In seaborn.</h2>\n<pre><code class=\"language-python\">import seaborn as sns\nsns.countplot(x='result', data=df)\n</code></pre>\n<h2>In plotly express</h2>\n<pre><code class=\"language-python\">import plotly.express as px\npx.histogram(df, x=\"result\")\n</code></pre>\n<p>If the graphs don't show, and you're using jupyter lab. Try:\n<code>jupyter labextension install jupyterlab-plotly@4.12.0</code></p>\n<hr>\n<p>I prefer to use seaborn for prettiest quick output.</p>"}},"coverImage":{"url":"https://www.datocms-assets.com/28985/1603898463-screenshot-2020-10-28-at-15-20-38.png","fluid":{"base64":"data:image/jpeg;base64,/9j/4AAQSkZJRgABAQEASABIAAD/4QBMRXhpZgAASUkqAAgAAAABAGmHBAABAAAAGgAAAAAAAAADAAGgAwABAAAA//8AAAKgBAABAAAAFAAAAAOgBAABAAAAAQAAAAAAAAD/2wEEEAAJAAsACwANABEADQASABQAFAASABgAGgAYABoAGAAkACEAHgAeACEAJAA2ACcAKQAnACkAJwA2AFEAMwA7ADMAMwA7ADMAUQBHAFYARwBCAEcAVgBHAIAAZQBZAFkAZQCAAJQAfAB2AHwAlACzAKAAoACzAOEA1QDhASUBJQGKEQAJAAsACwANABEADQASABQAFAASABgAGgAYABoAGAAkACEAHgAeACEAJAA2ACcAKQAnACkAJwA2AFEAMwA7ADMAMwA7ADMAUQBHAFYARwBCAEcAVgBHAIAAZQBZAFkAZQCAAJQAfAB2AHwAlACzAKAAoACzAOEA1QDhASUBJQGK/8IAEQgAAQAUAwEiAAIRAQMRAf/EACgAAQEAAAAAAAAAAAAAAAAAAAAHAQEBAAAAAAAAAAAAAAAAAAAAA//aAAwDAQACEAMQAAAAsIpMD//EABQQAQAAAAAAAAAAAAAAAAAAABD/2gAIAQEAAT8Af//EABQRAQAAAAAAAAAAAAAAAAAAABD/2gAIAQIBAT8AP//EABQRAQAAAAAAAAAAAAAAAAAAABD/2gAIAQMBAT8AP//Z","aspectRatio":1015,"src":"https://www.datocms-assets.com/28985/1603898463-screenshot-2020-10-28-at-15-20-38.png?auto=compress%2Cformat&fm=jpg","srcSet":"https://www.datocms-assets.com/28985/1603898463-screenshot-2020-10-28-at-15-20-38.png?auto=compress%2Cformat&dpr=0.08&fm=jpg&w=2030 150w,\nhttps://www.datocms-assets.com/28985/1603898463-screenshot-2020-10-28-at-15-20-38.png?auto=compress%2Cformat&dpr=0.15&fm=jpg&w=2030 300w,\nhttps://www.datocms-assets.com/28985/1603898463-screenshot-2020-10-28-at-15-20-38.png?auto=compress%2Cformat&dpr=0.3&fm=jpg&w=2030 600w,\nhttps://www.datocms-assets.com/28985/1603898463-screenshot-2020-10-28-at-15-20-38.png?auto=compress%2Cformat&dpr=0.45&fm=jpg&w=2030 900w,\nhttps://www.datocms-assets.com/28985/1603898463-screenshot-2020-10-28-at-15-20-38.png?auto=compress%2Cformat&dpr=0.6&fm=jpg&w=2030 1200w,\nhttps://www.datocms-assets.com/28985/1603898463-screenshot-2020-10-28-at-15-20-38.png?auto=compress%2Cformat&dpr=0.89&fm=jpg&w=2030 1800w,\nhttps://www.datocms-assets.com/28985/1603898463-screenshot-2020-10-28-at-15-20-38.png?auto=compress%2Cformat&dpr=1&fm=jpg&w=2030 2030w","sizes":"(max-width: 600px) 100vw, 600px"}}}},"pageContext":{"slug":"how-to-make-a-countplot-in-seaborn-plotly-and-matplotlib"}}}