{"id":147684,"date":"2021-01-05T19:00:48","date_gmt":"2021-01-05T16:00:48","guid":{"rendered":"https:\/\/en.buradabiliyorum.com\/a-beginners-guide-to-data-visualization-with-python-and-seaborn\/"},"modified":"2021-01-05T19:00:48","modified_gmt":"2021-01-05T16:00:48","slug":"a-beginners-guide-to-data-visualization-with-python-and-seaborn","status":"publish","type":"post","link":"https:\/\/buradabiliyorum.com\/en\/a-beginners-guide-to-data-visualization-with-python-and-seaborn\/","title":{"rendered":"#A beginner\u2019s guide to data visualization with Python and Seaborn"},"content":{"rendered":"<div id=\"ez-toc-container\" class=\"ez-toc-v2_0_84 counter-hierarchy ez-toc-counter ez-toc-custom ez-toc-container-direction\">\n<p class=\"ez-toc-title\" style=\"cursor:inherit\">Table of Contents<\/p>\n<label for=\"ez-toc-cssicon-toggle-item-6a2e1825dec10\" class=\"ez-toc-cssicon-toggle-label\"><span class=\"\"><span class=\"eztoc-hide\" style=\"display:none;\">Toggle<\/span><span class=\"ez-toc-icon-toggle-span\"><svg style=\"fill: #dd3333;color:#dd3333\" xmlns=\"http:\/\/www.w3.org\/2000\/svg\" class=\"list-377408\" width=\"20px\" height=\"20px\" viewBox=\"0 0 24 24\" fill=\"none\"><path d=\"M6 6H4v2h2V6zm14 0H8v2h12V6zM4 11h2v2H4v-2zm16 0H8v2h12v-2zM4 16h2v2H4v-2zm16 0H8v2h12v-2z\" fill=\"currentColor\"><\/path><\/svg><svg style=\"fill: #dd3333;color:#dd3333\" class=\"arrow-unsorted-368013\" xmlns=\"http:\/\/www.w3.org\/2000\/svg\" width=\"10px\" height=\"10px\" viewBox=\"0 0 24 24\" version=\"1.2\" baseProfile=\"tiny\"><path d=\"M18.2 9.3l-6.2-6.3-6.2 6.3c-.2.2-.3.4-.3.7s.1.5.3.7c.2.2.4.3.7.3h11c.3 0 .5-.1.7-.3.2-.2.3-.5.3-.7s-.1-.5-.3-.7zM5.8 14.7l6.2 6.3 6.2-6.3c.2-.2.3-.5.3-.7s-.1-.5-.3-.7c-.2-.2-.4-.3-.7-.3h-11c-.3 0-.5.1-.7.3-.2.2-.3.5-.3.7s.1.5.3.7z\"\/><\/svg><\/span><\/span><\/label><input type=\"checkbox\"  id=\"ez-toc-cssicon-toggle-item-6a2e1825dec10\" checked aria-label=\"Toggle\" \/><nav><ul class='ez-toc-list ez-toc-list-level-1 ' ><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-1\" href=\"https:\/\/buradabiliyorum.com\/en\/a-beginners-guide-to-data-visualization-with-python-and-seaborn\/#What_is_Seaborn\" >What is Seaborn?<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-2\" href=\"https:\/\/buradabiliyorum.com\/en\/a-beginners-guide-to-data-visualization-with-python-and-seaborn\/#Installing_Seaborn\" >Installing Seaborn<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-3\" href=\"https:\/\/buradabiliyorum.com\/en\/a-beginners-guide-to-data-visualization-with-python-and-seaborn\/#Building_your_first_plots\" >Building your first plots<\/a><ul class='ez-toc-list-level-3' ><li class='ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-4\" href=\"https:\/\/buradabiliyorum.com\/en\/a-beginners-guide-to-data-visualization-with-python-and-seaborn\/#Scatter_Plot\" >Scatter Plot<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-5\" href=\"https:\/\/buradabiliyorum.com\/en\/a-beginners-guide-to-data-visualization-with-python-and-seaborn\/#Line_Plot\" >Line Plot<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-6\" href=\"https:\/\/buradabiliyorum.com\/en\/a-beginners-guide-to-data-visualization-with-python-and-seaborn\/#Bar_Plot\" >Bar Plot<\/a><\/li><\/ul><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-7\" href=\"https:\/\/buradabiliyorum.com\/en\/a-beginners-guide-to-data-visualization-with-python-and-seaborn\/#Extending_with_matplotlib\" >Extending with matplotlib<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-8\" href=\"https:\/\/buradabiliyorum.com\/en\/a-beginners-guide-to-data-visualization-with-python-and-seaborn\/#Seaborn_loves_Pandas\" >Seaborn loves Pandas<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-9\" href=\"https:\/\/buradabiliyorum.com\/en\/a-beginners-guide-to-data-visualization-with-python-and-seaborn\/#Making_beautiful_plots_with_styles\" >Making beautiful plots with styles<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-10\" href=\"https:\/\/buradabiliyorum.com\/en\/a-beginners-guide-to-data-visualization-with-python-and-seaborn\/#Cool_use_cases\" >Cool use cases<\/a><ul class='ez-toc-list-level-3' ><li class='ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-11\" href=\"https:\/\/buradabiliyorum.com\/en\/a-beginners-guide-to-data-visualization-with-python-and-seaborn\/#Understanding_tip_percentages\" >Understanding tip percentages<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-12\" href=\"https:\/\/buradabiliyorum.com\/en\/a-beginners-guide-to-data-visualization-with-python-and-seaborn\/#Total_of_tips_per_day_of_the_week\" >Total of tips per day of the week<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-13\" href=\"https:\/\/buradabiliyorum.com\/en\/a-beginners-guide-to-data-visualization-with-python-and-seaborn\/#Impact_of_table_size_and_day_on_the_tip\" >Impact of table size and day on the tip<\/a><\/li><\/ul><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-14\" href=\"https:\/\/buradabiliyorum.com\/en\/a-beginners-guide-to-data-visualization-with-python-and-seaborn\/#Conclusion\" >Conclusion<\/a><\/li><\/ul><\/nav><\/div>\n<p>&#8220;<strong>#A beginner\u2019s guide to data visualization with Python and Seaborn<\/strong>&#8221;<\/p>\n<div>\n                            Data visualization is a technique that allows data scientists to convert raw data into charts and plots that generate valuable insights. Charts reduce the complexity of the data and make it easier to understand for any user.<\/p>\n<p>There are many tools to perform data visualization, such as Tableau, Power BI, ChartBlocks, and more, which are no-code tools. They are very powerful tools, and they have their audience. However, when working with raw data that requires transformation and a good playground for data, Python is an excellent choice.<\/p>\n<p>Though more complicated as it requires programming knowledge, Python allows you to perform any manipulation, transformation, and visualization of your data. It is ideal for data scientists.<\/p>\n<p>There are many reasons why Python is the best choice for data <a href=\"https:\/\/buradabiliyorum.com\/en\/category\/sciencee\/\" data-internallinksmanager029f6b8e52c=\"5\" title=\"Science\" target=\"_blank\" rel=\"noopener\">science<\/a>, but one of the most important ones is its ecosystem of libraries. Many great libraries are available for Python to work with data like<span>\u00a0<\/span><code>numpy<\/code>,<span>\u00a0<\/span><code>pandas<\/code>,<span>\u00a0<\/span><code>matplotlib<\/code>,<span>\u00a0<\/span><code>tensorflow<\/code>.<\/p>\n<p><code>Matplotlib<\/code><span>\u00a0<\/span>is probably the most recognized plotting library out there, available for Python and other programming languages like<span>\u00a0<\/span><code>R<\/code>. It is its level of customization and operability that set it in the first place. However, some actions or customizations can be hard to deal with when using it.<\/p>\n<p>Developers created a new library based on matplotlib called<span>\u00a0<\/span><code>seaborn<\/code>.<span>\u00a0<\/span><code>Seaborn<\/code><span>\u00a0<\/span>is as powerful as<span>\u00a0<\/span><code>matplotlib<\/code><span>\u00a0<\/span>while also providing an abstraction to simplify plots and bring some unique features.<\/p>\n<p>In this article, we will focus on how to work with Seaborn to create best-in-class plots. If you want to follow along you can create your own project or simply check out my<span>\u00a0<\/span><a rel=\"nofollow noopener\" target=\"_blank\" href=\"https:\/\/github.com\/bajcmartinez\/python-seaborn-guide\">seaborn guide project<\/a><span>\u00a0<\/span>on GitHub.<\/p>\n<h2 id=\"what-is-seaborn\"><span class=\"ez-toc-section\" id=\"What_is_Seaborn\"><\/span>What is Seaborn?<span class=\"ez-toc-section-end\"><\/span><\/h2>\n<p><a rel=\"nofollow noopener\" target=\"_blank\" href=\"https:\/\/seaborn.pydata.org\/\">Seaborn<\/a><span>\u00a0<\/span>is a library for making statistical graphics in Python. It builds on top of<span>\u00a0<\/span><a rel=\"nofollow noopener\" target=\"_blank\" href=\"https:\/\/matplotlib.org\/\">matplotlib<\/a><span>\u00a0<\/span>and integrates closely with<span>\u00a0<\/span><a rel=\"nofollow noopener\" target=\"_blank\" href=\"https:\/\/livecodestream.dev\/post\/how-to-work-with-pandas-in-python\/\">pandas data structures<\/a><span>\u00a0<\/span>.<\/p>\n<p>Seaborn design allows you to explore and understand your data quickly. Seaborn works by capturing entire data frames or arrays containing all your data and performing all the internal functions necessary for semantic m<a href=\"https:\/\/buradabiliyorum.com\/en\/category\/download-scripts-themes-apps\/\" data-internallinksmanager029f6b8e52c=\"9\" title=\"Download Scripts &amp; Themes &amp; Apps\" target=\"_blank\" rel=\"noopener\">app<\/a>ing and statistical aggregation to convert data into informative plots.<\/p>\n<p>It abstracts complexity while allowing you to design your plots to your requirements.<\/p>\n<p><em>[Read:\u00a0<span dir=\"auto\">Meet the 4 scale-ups using data to save the planet]<\/span><\/em><\/p>\n<h2 id=\"installing-seaborn\"><span class=\"ez-toc-section\" id=\"Installing_Seaborn\"><\/span>Installing Seaborn<span class=\"ez-toc-section-end\"><\/span><\/h2>\n<p>Installing<span>\u00a0<\/span><code>seaborn<\/code><span>\u00a0<\/span>is as easy as installing one library using your favorite Python package manager. When installing<span>\u00a0<\/span><code>seaborn<\/code>, the library will install its dependencies, including<span>\u00a0<\/span><code>matplotlib<\/code>,<span>\u00a0<\/span><code>pandas<\/code>,<span>\u00a0<\/span><code>numpy<\/code>, and<span>\u00a0<\/span><code>scipy<\/code>.<\/p>\n<p>Let\u2019s then install Seaborn, and of course, also the package<span>\u00a0<\/span><a rel=\"nofollow noopener\" target=\"_blank\" href=\"https:\/\/jupyter.org\/\">notebook<\/a><span>\u00a0<\/span>to get access to our data playground.<\/p>\n<div class=\"highlight\">\n<pre><code class=\"language-text\" data-lang=\"text\">pipenv install seaborn notebook&#13;\n<\/code><\/pre>\n<\/div>\n<p>Additionally, we are going to import a few modules before we get started.<\/p>\n<div class=\"highlight\">\n<pre><code class=\"language-python\" data-lang=\"python\"><span>import<\/span> seaborn <span>as<\/span> sns&#13;\n<span>import<\/span> pandas <span>as<\/span> pd&#13;\n<span>import<\/span> numpy <span>as<\/span> np&#13;\n<span>import<\/span> matplotlib&#13;\n<\/code><\/pre>\n<\/div>\n<h2 id=\"building-your-first-plots\"><span class=\"ez-toc-section\" id=\"Building_your_first_plots\"><\/span>Building your first plots<span class=\"ez-toc-section-end\"><\/span><\/h2>\n<p>Before we can start plotting anything, we need data. The beauty of<span>\u00a0<\/span><code>seaborn<\/code><span>\u00a0<\/span>is that it works directly with<span>\u00a0<\/span><code>pandas<\/code><span>\u00a0<\/span>dataframes, making it super convenient. Even more so, the library comes with some built-in datasets that you can now load from code, no need to manually downloading files.<\/p>\n<p>Let\u2019s see how that works by loading a dataset that contains information about flights.<\/p>\n<figure class=\"post-image post-mediaBleed alignnone\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone wp-image-1333099 lazy\" alt=\"\" width=\"737\" height=\"440\" sizes=\"auto, (max-width: 737px) 100vw, 737px\" src=\"https:\/\/cdn0.tnwcdn.com\/wp-content\/blogs.dir\/1\/files\/2021\/01\/Screenshot-2021-01-05-at-13.57.22.png\" data-lazy=\"true\" srcset=\"https:\/\/cdn0.tnwcdn.com\/wp-content\/blogs.dir\/1\/files\/2021\/01\/Screenshot-2021-01-05-at-13.57.22.png 928w, https:\/\/cdn0.tnwcdn.com\/wp-content\/blogs.dir\/1\/files\/2021\/01\/Screenshot-2021-01-05-at-13.57.22-280x167.png 280w, https:\/\/cdn0.tnwcdn.com\/wp-content\/blogs.dir\/1\/files\/2021\/01\/Screenshot-2021-01-05-at-13.57.22-452x270.png 452w, https:\/\/cdn0.tnwcdn.com\/wp-content\/blogs.dir\/1\/files\/2021\/01\/Screenshot-2021-01-05-at-13.57.22-226x135.png 226w, https:\/\/cdn0.tnwcdn.com\/wp-content\/blogs.dir\/1\/files\/2021\/01\/Screenshot-2021-01-05-at-13.57.22-796x475.png 796w\"\/><\/figure>\n<h3 id=\"scatter-plot\"><span class=\"ez-toc-section\" id=\"Scatter_Plot\"><\/span>Scatter Plot<span class=\"ez-toc-section-end\"><\/span><\/h3>\n<p>A scatter plot is a diagram that displays points based on two dimensions of the dataset. Creating a scatter plot in the Seaborn library is so simple and with just one line of code.<\/p>\n<pre><code>sns.scatterplot(data=flights_data, x=\"year\", y=\"passengers\")&#13;\n<\/code><\/pre>\n<figure class=\"\" data-src=\"https:\/\/thenextweb.com\/post\/how-to-build-beautiful-plots-with-python-and-seaborn\/scatter_hu8c145c17714d63fee15d2a018c066908_16242_700x0_resize_box_2.png\">\n<figure class=\"post-image post-mediaBleed aligncenter\"><img loading=\"lazy\" decoding=\"async\" class=\"lazy loaded lazy\" alt=\"\" width=\"643\" height=\"449\" src=\"https:\/\/livecodestream.dev\/post\/how-to-build-beautiful-plots-with-python-and-seaborn\/scatter_hu8c145c17714d63fee15d2a018c066908_16242_700x0_resize_box_2.png\" data-lazy=\"true\"\/><figcaption><a rel=\"nofollow noopener\" target=\"_blank\" href=\"https:\/\/thenextweb.com\/syndication\/2021\/01\/05\/a-beginners-guide-to-data-visualization-with-python-and-seaborn\/#\" data-url=\"https:\/\/twitter.com\/intent\/tweet?url=https%3A%2F%2Fthenextweb.com%2Fsyndication%2F2021%2F01%2F05%2Fa-beginners-guide-to-data-visualization-with-python-and-seaborn%2F&amp;via=thenextweb&amp;related=thenextweb&amp;text=Check out this picture on: Sample scatter plot\" data-title=\"Share Sample scatter plot on Twitter\" data-width=\"685\" data-height=\"500\" class=\"post-image-share popitup\" title=\"Share Sample scatter plot on Twitter\"><i class=\"icon icon--inline icon--twitter--dark\"\/><\/a>Sample scatter plot<\/figcaption><\/figure>\n<\/p>\n<\/figure>\n<p>Very easy, right? The function<span>\u00a0<\/span><code>scatterplot<\/code><span>\u00a0<\/span>expects the dataset we want to plot and the columns representing the<span>\u00a0<\/span><code>x<\/code><span>\u00a0<\/span>and<span>\u00a0<\/span><code>y<\/code><span>\u00a0<\/span>axis.<\/p>\n<h3 id=\"line-plot\"><span class=\"ez-toc-section\" id=\"Line_Plot\"><\/span>Line Plot<span class=\"ez-toc-section-end\"><\/span><\/h3>\n<p>This plot draws a line that represents the revolution of continuous or categorical data. It is a popular and known type of chart, and it\u2019s super easy to produce. Similarly to before, we use the function<span>\u00a0<\/span><code>lineplot<\/code><span>\u00a0<\/span>with the dataset and the columns representing the<span>\u00a0<\/span><code>x<\/code><span>\u00a0<\/span>and<span>\u00a0<\/span><code>y<\/code><span>\u00a0<\/span>axis.<span>\u00a0<\/span><code>Seaborn<\/code><span>\u00a0<\/span>will do the rest.<\/p>\n<div class=\"highlight\">\n<pre><code class=\"language-python\" data-lang=\"python\">sns<span>.<\/span>lineplot(data<span>=flights<\/span>_data, x<span>=<\/span><span>\"year\"<\/span>, y<span>=<\/span><span>\"passengers\"<\/span>)&#13;\n<\/code><\/pre>\n<\/div>\n<figure class=\"\" data-src=\"https:\/\/thenextweb.com\/post\/how-to-build-beautiful-plots-with-python-and-seaborn\/line_hu8d87bc669c476373da06acfb76abbc49_28570_700x0_resize_box_2.png\">\n<figure class=\"post-image post-mediaBleed aligncenter\"><img loading=\"lazy\" decoding=\"async\" class=\"lazy loaded lazy\" alt=\"\" width=\"700\" height=\"489\" src=\"https:\/\/livecodestream.dev\/post\/how-to-build-beautiful-plots-with-python-and-seaborn\/line_hu8d87bc669c476373da06acfb76abbc49_28570_700x0_resize_box_2.png\" data-lazy=\"true\"\/><figcaption><a rel=\"nofollow noopener\" target=\"_blank\" href=\"https:\/\/thenextweb.com\/syndication\/2021\/01\/05\/a-beginners-guide-to-data-visualization-with-python-and-seaborn\/#\" data-url=\"https:\/\/twitter.com\/intent\/tweet?url=https%3A%2F%2Fthenextweb.com%2Fsyndication%2F2021%2F01%2F05%2Fa-beginners-guide-to-data-visualization-with-python-and-seaborn%2F&amp;via=thenextweb&amp;related=thenextweb&amp;text=Check out this picture on: Sample line plot\" data-title=\"Share Sample line plot on Twitter\" data-width=\"685\" data-height=\"500\" class=\"post-image-share popitup\" title=\"Share Sample line plot on Twitter\"><i class=\"icon icon--inline icon--twitter--dark\"\/><\/a>Sample line plot<\/figcaption><\/figure>\n<\/p>\n<\/figure>\n<h3 id=\"bar-plot\"><span class=\"ez-toc-section\" id=\"Bar_Plot\"><\/span>Bar Plot<span class=\"ez-toc-section-end\"><\/span><\/h3>\n<p>It is probably the best-known type of chart, and as you may have predicted, we can plot this type of plot with<span>\u00a0<\/span><code>seaborn<\/code><span>\u00a0<\/span>in the same way we do for lines and scatter plots by using the function<span>\u00a0<\/span><code>barplot<\/code>.<\/p>\n<div class=\"highlight\">\n<pre><code class=\"language-python\" data-lang=\"python\">sns<span>.<\/span>barplot(data<span>=flights<\/span>_data, x<span>=<\/span><span>\"year\"<\/span>, y<span>=<\/span><span>\"passengers\"<\/span>)&#13;\n<\/code><\/pre>\n<\/div>\n<figure class=\"lph\" data-src=\"https:\/\/thenextweb.com\/post\/how-to-build-beautiful-plots-with-python-and-seaborn\/bar_hu582125c43761c6433dd9c8fa01845a48_8748_700x0_resize_box_2.png\">\n<figure class=\"post-image post-mediaBleed aligncenter\"><img loading=\"lazy\" decoding=\"async\" alt=\"\" width=\"700\" height=\"489\" class=\" lazy\" src=\"https:\/\/livecodestream.dev\/post\/how-to-build-beautiful-plots-with-python-and-seaborn\/bar_hu582125c43761c6433dd9c8fa01845a48_8748_700x0_resize_box_2.png\" data-lazy=\"true\"\/><figcaption><a rel=\"nofollow noopener\" target=\"_blank\" href=\"https:\/\/thenextweb.com\/syndication\/2021\/01\/05\/a-beginners-guide-to-data-visualization-with-python-and-seaborn\/#\" data-url=\"https:\/\/twitter.com\/intent\/tweet?url=https%3A%2F%2Fthenextweb.com%2Fsyndication%2F2021%2F01%2F05%2Fa-beginners-guide-to-data-visualization-with-python-and-seaborn%2F&amp;via=thenextweb&amp;related=thenextweb&amp;text=Check out this picture on: Sample bar plot\" data-title=\"Share Sample bar plot on Twitter\" data-width=\"685\" data-height=\"500\" class=\"post-image-share popitup\" title=\"Share Sample bar plot on Twitter\"><i class=\"icon icon--inline icon--twitter--dark\"\/><\/a>Sample bar plot<\/figcaption><\/figure>\n<\/p>\n<\/figure>\n<p>It\u2019s very colorful, I know, we will learn how to customize it later on in the guide.<\/p>\n<h2 id=\"extending-with-matplotlib\"><span class=\"ez-toc-section\" id=\"Extending_with_matplotlib\"><\/span>Extending with matplotlib<span class=\"ez-toc-section-end\"><\/span><\/h2>\n<p>Seaborn builds on top of<span>\u00a0<\/span><code>matplotlib<\/code>, extending its functionality and abstracting complexity. With that said, it does not limit its capabilities. Any<span>\u00a0<\/span><code>seaborn<\/code><span>\u00a0<\/span>chart can be customized using functions from the<span>\u00a0<\/span><code>matplotlib<\/code><span>\u00a0<\/span>library. It can come in handy for specific operations and allows seaborn to leverage the power of<span>\u00a0<\/span><code>matplotlib<\/code><span>\u00a0<\/span>without having to rewrite all its functions.<\/p>\n<p>Let\u2019s say that you, for example, want to plot multiple graphs simultaneously using<span>\u00a0<\/span><code>seaborn<\/code>; then you could use the<span>\u00a0<\/span><code>subplot<\/code><span>\u00a0<\/span>function from<span>\u00a0<\/span><code>matplotlib<\/code>.<\/p>\n<div class=\"highlight\">\n<pre><code class=\"language-python\" data-lang=\"python\">diamonds_data <span>=<\/span> sns<span>.<\/span>load_dataset(<span>'diamonds'<\/span>)&#13;\nplt<span>.<\/span>subplot(<span>1<\/span>, <span>2<\/span>, <span>1<\/span>)&#13;\nsns<span>.<\/span>countplot(x<span>=<\/span><span>'carat'<\/span>, data<span>=<\/span>diamonds_data)&#13;\nplt<span>.<\/span>subplot(<span>1<\/span>, <span>2<\/span>, <span>2<\/span>)&#13;\nsns<span>.<\/span>countplot(x<span>=<\/span><span>'depth'<\/span>, data<span>=<\/span>diamonds_data)&#13;\n<\/code><\/pre>\n<\/div>\n<figure class=\"\" data-src=\"https:\/\/thenextweb.com\/post\/how-to-build-beautiful-plots-with-python-and-seaborn\/extending_hudb3c7d41b2118b98fbd37c34ef916ea4_14342_700x0_resize_box_2.png\">\n<figure class=\"post-image post-mediaBleed aligncenter\"><img loading=\"lazy\" decoding=\"async\" class=\"lazy loaded lazy\" alt=\"\" width=\"700\" height=\"478\" src=\"https:\/\/livecodestream.dev\/post\/how-to-build-beautiful-plots-with-python-and-seaborn\/extending_hudb3c7d41b2118b98fbd37c34ef916ea4_14342_700x0_resize_box_2.png\" data-lazy=\"true\"\/><figcaption><a rel=\"nofollow noopener\" target=\"_blank\" href=\"https:\/\/thenextweb.com\/syndication\/2021\/01\/05\/a-beginners-guide-to-data-visualization-with-python-and-seaborn\/#\" data-url=\"https:\/\/twitter.com\/intent\/tweet?url=https%3A%2F%2Fthenextweb.com%2Fsyndication%2F2021%2F01%2F05%2Fa-beginners-guide-to-data-visualization-with-python-and-seaborn%2F&amp;via=thenextweb&amp;related=thenextweb&amp;text=Check out this picture on: Sample plot with sub-plots\" data-title=\"Share Sample plot with sub-plots on Twitter\" data-width=\"685\" data-height=\"500\" class=\"post-image-share popitup\" title=\"Share Sample plot with sub-plots on Twitter\"><i class=\"icon icon--inline icon--twitter--dark\"\/><\/a>Sample plot with sub-plots<\/figcaption><\/figure>\n<\/p>\n<\/figure>\n<p>Using the<span>\u00a0<\/span><code>subplot<\/code><span>\u00a0<\/span>function, we can draw more than one chart on a single plot. The function takes three parameters, the first is the number of rows, the second is the number of columns, and the last one is the plot number.<\/p>\n<p>We are rendering a<span>\u00a0<\/span><code>seaborn<\/code><span>\u00a0<\/span>chart in each subplot, mixing<span>\u00a0<\/span><code>matplotlib<\/code><span>\u00a0<\/span>with<span>\u00a0<\/span><code>seaborn<\/code><span>\u00a0<\/span>functions.<\/p>\n<h2 id=\"seaborn-loves-pandas\"><span class=\"ez-toc-section\" id=\"Seaborn_loves_Pandas\"><\/span>Seaborn loves Pandas<span class=\"ez-toc-section-end\"><\/span><\/h2>\n<p>We already talked about this, but<span>\u00a0<\/span><code>seaborn<\/code><span>\u00a0<\/span>loves<span>\u00a0<\/span><code>pandas<\/code><span>\u00a0<\/span>to such an extent that all its functions build on top of the<span>\u00a0<\/span><code>pandas<\/code><span>\u00a0<\/span>dataframe. So far, we saw examples of using<span>\u00a0<\/span><code>seaborn<\/code><span>\u00a0<\/span>with pre-loaded data, but what if we want to draw a plot from data we already have loaded using<span>\u00a0<\/span><code>pandas<\/code>?<\/p>\n<div class=\"highlight\">\n<pre><code class=\"language-python\" data-lang=\"python\">drinks_df <span>=<\/span> pd<span>.<\/span>read_csv(<span>\"data\/drinks.csv\"<\/span>)&#13;\nsns<span>.<\/span>barplot(x<span>=<\/span><span>\"country\"<\/span>, y<span>=<\/span><span>\"beer_servings\"<\/span>, data<span>=<\/span>drinks_df)&#13;\n<\/code><\/pre>\n<\/div>\n<figure class=\"\" data-src=\"https:\/\/thenextweb.com\/post\/how-to-build-beautiful-plots-with-python-and-seaborn\/pandas_hu829852d1c87d1926dc22a5c412120685_15392_700x0_resize_box_2.png\">\n<figure class=\"post-image post-mediaBleed aligncenter\"><img loading=\"lazy\" decoding=\"async\" class=\"lazy loaded lazy\" alt=\"\" width=\"700\" height=\"472\" src=\"https:\/\/livecodestream.dev\/post\/how-to-build-beautiful-plots-with-python-and-seaborn\/pandas_hu829852d1c87d1926dc22a5c412120685_15392_700x0_resize_box_2.png\" data-lazy=\"true\"\/><figcaption><a rel=\"nofollow noopener\" target=\"_blank\" href=\"https:\/\/thenextweb.com\/syndication\/2021\/01\/05\/a-beginners-guide-to-data-visualization-with-python-and-seaborn\/#\" data-url=\"https:\/\/twitter.com\/intent\/tweet?url=https%3A%2F%2Fthenextweb.com%2Fsyndication%2F2021%2F01%2F05%2Fa-beginners-guide-to-data-visualization-with-python-and-seaborn%2F&amp;via=thenextweb&amp;related=thenextweb&amp;text=Check out this picture on: Sample plot with pandas\" data-title=\"Share Sample plot with pandas on Twitter\" data-width=\"685\" data-height=\"500\" class=\"post-image-share popitup\" title=\"Share Sample plot with pandas on Twitter\"><i class=\"icon icon--inline icon--twitter--dark\"\/><\/a>Sample plot with pandas<\/figcaption><\/figure>\n<\/p>\n<\/figure>\n<h2 id=\"making-beautiful-plots-with-styles\"><span class=\"ez-toc-section\" id=\"Making_beautiful_plots_with_styles\"><\/span>Making beautiful plots with styles<span class=\"ez-toc-section-end\"><\/span><\/h2>\n<p>Seaborn gives you the ability to change your graphs\u2019 interface, and it provides five different styles out of the box:<span>\u00a0<\/span><strong>darkgrid<\/strong>,<span>\u00a0<\/span><strong>whitegrid<\/strong>,<span>\u00a0<\/span><strong>dark<\/strong>,<span>\u00a0<\/span><strong>white<\/strong>, and<span>\u00a0<\/span><strong>ticks<\/strong>.<\/p>\n<div class=\"highlight\">\n<pre><code class=\"language-python\" data-lang=\"python\">sns<span>.<\/span>set_style(<span>\"darkgrid\"<\/span>)&#13;\nsns<span>.<\/span>lineplot(data <span>=<\/span> data, x <span>=<\/span> <span>\"year\"<\/span>, y <span>=<\/span> <span>\"passengers\"<\/span>)&#13;\n<\/code><\/pre>\n<\/div>\n<figure class=\"lph\" data-src=\"https:\/\/thenextweb.com\/post\/how-to-build-beautiful-plots-with-python-and-seaborn\/style-darkgrid_hucf45549107692f6d02507c3af4af595c_30522_700x0_resize_box_2.png\">\n<figure class=\"post-image post-mediaBleed aligncenter\"><img loading=\"lazy\" decoding=\"async\" alt=\"\" width=\"700\" height=\"489\" class=\" lazy\" src=\"https:\/\/livecodestream.dev\/post\/how-to-build-beautiful-plots-with-python-and-seaborn\/style-darkgrid_hucf45549107692f6d02507c3af4af595c_30522_700x0_resize_box_2.png\" data-lazy=\"true\"\/><figcaption><a rel=\"nofollow noopener\" target=\"_blank\" href=\"https:\/\/thenextweb.com\/syndication\/2021\/01\/05\/a-beginners-guide-to-data-visualization-with-python-and-seaborn\/#\" data-url=\"https:\/\/twitter.com\/intent\/tweet?url=https%3A%2F%2Fthenextweb.com%2Fsyndication%2F2021%2F01%2F05%2Fa-beginners-guide-to-data-visualization-with-python-and-seaborn%2F&amp;via=thenextweb&amp;related=thenextweb&amp;text=Check out this picture on: Sample plot with darkgrid style\" data-title=\"Share Sample plot with darkgrid style on Twitter\" data-width=\"685\" data-height=\"500\" class=\"post-image-share popitup\" title=\"Share Sample plot with darkgrid style on Twitter\"><i class=\"icon icon--inline icon--twitter--dark\"\/><\/a>Sample plot with darkgrid style<\/figcaption><\/figure>\n<\/p>\n<\/figure>\n<p>Here is another example<\/p>\n<div class=\"highlight\">\n<pre><code class=\"language-python\" data-lang=\"python\">sns<span>.<\/span>set_style(<span>\"whitegrid\"<\/span>)&#13;\nsns<span>.<\/span>lineplot(data<span>=flights<\/span>_data, x<span>=<\/span><span>\"year\"<\/span>, y<span>=<\/span><span>\"passengers\"<\/span>)&#13;\n<\/code><\/pre>\n<\/div>\n<figure class=\"\" data-src=\"https:\/\/thenextweb.com\/post\/how-to-build-beautiful-plots-with-python-and-seaborn\/style-whitegrid_huee49c3cd5b65b1c39ac9e88d98bb041f_31252_700x0_resize_box_2.png\">\n<figure class=\"post-image post-mediaBleed aligncenter\"><img loading=\"lazy\" decoding=\"async\" class=\"lazy loaded lazy\" alt=\"\" width=\"700\" height=\"489\" src=\"https:\/\/livecodestream.dev\/post\/how-to-build-beautiful-plots-with-python-and-seaborn\/style-whitegrid_huee49c3cd5b65b1c39ac9e88d98bb041f_31252_700x0_resize_box_2.png\" data-lazy=\"true\"\/><figcaption><a rel=\"nofollow noopener\" target=\"_blank\" href=\"https:\/\/thenextweb.com\/syndication\/2021\/01\/05\/a-beginners-guide-to-data-visualization-with-python-and-seaborn\/#\" data-url=\"https:\/\/twitter.com\/intent\/tweet?url=https%3A%2F%2Fthenextweb.com%2Fsyndication%2F2021%2F01%2F05%2Fa-beginners-guide-to-data-visualization-with-python-and-seaborn%2F&amp;via=thenextweb&amp;related=thenextweb&amp;text=Check out this picture on: Sample plot with whitegrid style\" data-title=\"Share Sample plot with whitegrid style on Twitter\" data-width=\"685\" data-height=\"500\" class=\"post-image-share popitup\" title=\"Share Sample plot with whitegrid style on Twitter\"><i class=\"icon icon--inline icon--twitter--dark\"\/><\/a>Sample plot with whitegrid style<\/figcaption><\/figure>\n<\/p>\n<\/figure>\n<h2 id=\"cool-use-cases\"><span class=\"ez-toc-section\" id=\"Cool_use_cases\"><\/span>Cool use cases<span class=\"ez-toc-section-end\"><\/span><\/h2>\n<p>We know the basics of<span>\u00a0<\/span><code>seaborn<\/code>, now let\u2019s get them into practice by building multiple charts over the same dataset. In our case, we will use the dataset \u201ctips\u201d that you can download directly using<span>\u00a0<\/span><code>seaborn<\/code>.<\/p>\n<p>First, load the dataset.<\/p>\n<figure class=\"post-image post-mediaBleed alignnone\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone wp-image-1333095 lazy\" alt=\"\" width=\"778\" height=\"476\" sizes=\"auto, (max-width: 778px) 100vw, 778px\" src=\"https:\/\/cdn0.tnwcdn.com\/wp-content\/blogs.dir\/1\/files\/2021\/01\/Screenshot-2021-01-05-at-13.51.24.png\" data-lazy=\"true\" srcset=\"https:\/\/cdn0.tnwcdn.com\/wp-content\/blogs.dir\/1\/files\/2021\/01\/Screenshot-2021-01-05-at-13.51.24.png 936w, https:\/\/cdn0.tnwcdn.com\/wp-content\/blogs.dir\/1\/files\/2021\/01\/Screenshot-2021-01-05-at-13.51.24-280x171.png 280w, https:\/\/cdn0.tnwcdn.com\/wp-content\/blogs.dir\/1\/files\/2021\/01\/Screenshot-2021-01-05-at-13.51.24-442x270.png 442w, https:\/\/cdn0.tnwcdn.com\/wp-content\/blogs.dir\/1\/files\/2021\/01\/Screenshot-2021-01-05-at-13.51.24-221x135.png 221w, https:\/\/cdn0.tnwcdn.com\/wp-content\/blogs.dir\/1\/files\/2021\/01\/Screenshot-2021-01-05-at-13.51.24-796x486.png 796w\"\/><\/figure>\n<div class=\"highlight\">\n<pre><span style=\"font-family: Georgia, 'Times New Roman', 'Bitstream Charter', Times, serif;\">I like to print the first few rows of the data set to get a feeling of the columns and the data itself. Usually, I use some<\/span><span style=\"font-family: Georgia, 'Times New Roman', 'Bitstream Charter', Times, serif;\">\u00a0<\/span><span style=\"font-family: Georgia, 'Times New Roman', 'Bitstream Charter', Times, serif;\"\/><code>pandas<\/code><span style=\"font-family: Georgia, 'Times New Roman', 'Bitstream Charter', Times, serif;\">\u00a0<\/span><span style=\"font-family: Georgia, 'Times New Roman', 'Bitstream Charter', Times, serif;\">functions to fix some data issues like<\/span><span style=\"font-family: Georgia, 'Times New Roman', 'Bitstream Charter', Times, serif;\">\u00a0<\/span><span style=\"font-family: Georgia, 'Times New Roman', 'Bitstream Charter', Times, serif;\"\/><code>null<\/code><span style=\"font-family: Georgia, 'Times New Roman', 'Bitstream Charter', Times, serif;\">\u00a0<\/span><span style=\"font-family: Georgia, 'Times New Roman', 'Bitstream Charter', Times, serif;\">values and add information to the data set that may be helpful. You can read more about this on the<\/span><span style=\"font-family: Georgia, 'Times New Roman', 'Bitstream Charter', Times, serif;\">\u00a0<\/span><span style=\"font-family: Georgia, 'Times New Roman', 'Bitstream Charter', Times, serif;\"\/><a rel=\"nofollow noopener\" target=\"_blank\" style=\"font-family: Georgia, 'Times New Roman', 'Bitstream Charter', Times, serif;\" href=\"https:\/\/livecodestream.dev\/post\/how-to-work-with-pandas-in-python\/\">guide to working with pandas<\/a><span style=\"font-family: Georgia, 'Times New Roman', 'Bitstream Charter', Times, serif;\">\u00a0<\/span><span style=\"font-family: Georgia, 'Times New Roman', 'Bitstream Charter', Times, serif;\">.<\/span><\/pre>\n<\/div>\n<p>Let\u2019s create an additional column to the data set with the percentage that represents the tip amount over the total of the bill.<\/p>\n<p><span style=\"font-family: Consolas, Monaco, monospace;\"><\/p>\n<figure class=\"post-image post-mediaBleed alignnone\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone wp-image-1333096 lazy\" alt=\"\" width=\"811\" height=\"565\" sizes=\"auto, (max-width: 811px) 100vw, 811px\" src=\"https:\/\/cdn0.tnwcdn.com\/wp-content\/blogs.dir\/1\/files\/2021\/01\/Screenshot-2021-01-05-at-13.52.03.png\" data-lazy=\"true\" srcset=\"https:\/\/cdn0.tnwcdn.com\/wp-content\/blogs.dir\/1\/files\/2021\/01\/Screenshot-2021-01-05-at-13.52.03.png 970w, https:\/\/cdn0.tnwcdn.com\/wp-content\/blogs.dir\/1\/files\/2021\/01\/Screenshot-2021-01-05-at-13.52.03-280x195.png 280w, https:\/\/cdn0.tnwcdn.com\/wp-content\/blogs.dir\/1\/files\/2021\/01\/Screenshot-2021-01-05-at-13.52.03-387x270.png 387w, https:\/\/cdn0.tnwcdn.com\/wp-content\/blogs.dir\/1\/files\/2021\/01\/Screenshot-2021-01-05-at-13.52.03-194x135.png 194w, https:\/\/cdn0.tnwcdn.com\/wp-content\/blogs.dir\/1\/files\/2021\/01\/Screenshot-2021-01-05-at-13.52.03-796x555.png 796w\"\/><\/figure>\n<p><\/span><\/p>\n<p>Next, we can start plotting some charts.<\/p>\n<h3 id=\"understanding-tip-percentages\"><span class=\"ez-toc-section\" id=\"Understanding_tip_percentages\"><\/span>Understanding tip percentages<span class=\"ez-toc-section-end\"><\/span><\/h3>\n<p>Let\u2019s try first to understand the tip percentage distribution. For that, we can use<span>\u00a0<\/span><code>histplot<\/code><span>\u00a0<\/span>that will generate a histogram chart.<\/p>\n<div class=\"highlight\">\n<pre><code class=\"language-python\" data-lang=\"python\">sns<span>.<\/span>histplot(tips_df[<span>\"tip_percentage\"<\/span>], binwidth<span>=<\/span><span>0.05<\/span>)&#13;\n<\/code><\/pre>\n<\/div>\n<figure class=\"\" data-src=\"https:\/\/thenextweb.com\/post\/how-to-build-beautiful-plots-with-python-and-seaborn\/tip-percentages_hu2927fbe982b4f0d35b701c3d310cf773_8956_700x0_resize_box_2.png\">\n<figure class=\"post-image post-mediaBleed aligncenter\"><img loading=\"lazy\" decoding=\"async\" class=\"lazy loaded lazy\" alt=\"\" width=\"700\" height=\"490\" src=\"https:\/\/livecodestream.dev\/post\/how-to-build-beautiful-plots-with-python-and-seaborn\/tip-percentages_hu2927fbe982b4f0d35b701c3d310cf773_8956_700x0_resize_box_2.png\" data-lazy=\"true\"\/><figcaption><a rel=\"nofollow noopener\" target=\"_blank\" href=\"https:\/\/thenextweb.com\/syndication\/2021\/01\/05\/a-beginners-guide-to-data-visualization-with-python-and-seaborn\/#\" data-url=\"https:\/\/twitter.com\/intent\/tweet?url=https%3A%2F%2Fthenextweb.com%2Fsyndication%2F2021%2F01%2F05%2Fa-beginners-guide-to-data-visualization-with-python-and-seaborn%2F&amp;via=thenextweb&amp;related=thenextweb&amp;text=Check out this picture on: Understanding tip percentages plot\" data-title=\"Share Understanding tip percentages plot on Twitter\" data-width=\"685\" data-height=\"500\" class=\"post-image-share popitup\" title=\"Share Understanding tip percentages plot on Twitter\"><i class=\"icon icon--inline icon--twitter--dark\"\/><\/a>Understanding tip percentages plot<\/figcaption><\/figure>\n<\/p>\n<\/figure>\n<p>That\u2019s good, we had to customize the<span>\u00a0<\/span><code>binwidth<\/code><span>\u00a0<\/span>property to make it more readable, but now we can quickly appreciate our understanding of the data. Most customers would tip between 15 to 20%, and we have some edge cases where the tip is over 70%. Those values are anomalies, and they are always worth exploring to determine if the values are errors or not.<\/p>\n<p>It would also be interesting to know if the tip percentage changes depending on the moment of the day,<\/p>\n<div class=\"highlight\">\n<pre><code class=\"language-python\" data-lang=\"python\">sns<span>.<\/span>histplot(data<span>=<\/span>tips_df, x<span>=<\/span><span>\"tip_percentage\"<\/span>, binwidth<span>=<\/span><span>0.05<\/span>, hue<span>=<\/span><span>\"time\"<\/span>)&#13;\n<\/code><\/pre>\n<\/div>\n<figure class=\"\" data-src=\"https:\/\/thenextweb.com\/post\/how-to-build-beautiful-plots-with-python-and-seaborn\/hue_hu391f91c0b2935fe091908e84631efd90_11559_700x0_resize_box_2.png\">\n<figure class=\"post-image post-mediaBleed aligncenter\"><img loading=\"lazy\" decoding=\"async\" class=\"lazy loaded lazy\" alt=\"\" width=\"700\" height=\"495\" src=\"https:\/\/livecodestream.dev\/post\/how-to-build-beautiful-plots-with-python-and-seaborn\/hue_hu391f91c0b2935fe091908e84631efd90_11559_700x0_resize_box_2.png\" data-lazy=\"true\"\/><figcaption><a rel=\"nofollow noopener\" target=\"_blank\" href=\"https:\/\/thenextweb.com\/syndication\/2021\/01\/05\/a-beginners-guide-to-data-visualization-with-python-and-seaborn\/#\" data-url=\"https:\/\/twitter.com\/intent\/tweet?url=https%3A%2F%2Fthenextweb.com%2Fsyndication%2F2021%2F01%2F05%2Fa-beginners-guide-to-data-visualization-with-python-and-seaborn%2F&amp;via=thenextweb&amp;related=thenextweb&amp;text=Check out this picture on: Understanding tip percentages by time plot\" data-title=\"Share Understanding tip percentages by time plot on Twitter\" data-width=\"685\" data-height=\"500\" class=\"post-image-share popitup\" title=\"Share Understanding tip percentages by time plot on Twitter\"><i class=\"icon icon--inline icon--twitter--dark\"\/><\/a>Understanding tip percentages by time plot<\/figcaption><\/figure>\n<\/p>\n<\/figure>\n<p>This time we loaded the chart with the full dataset instead of just one column, and then we set the property<span>\u00a0<\/span><code>hue<\/code><span>\u00a0<\/span>to the column<span>\u00a0<\/span><code>time<\/code>. This will force the chart to use different colors for each value of<span>\u00a0<\/span><code>time<\/code><span>\u00a0<\/span>and add a legend to it.<\/p>\n<h3 id=\"total-of-tips-per-day-of-the-week\"><span class=\"ez-toc-section\" id=\"Total_of_tips_per_day_of_the_week\"><\/span>Total of tips per day of the week<span class=\"ez-toc-section-end\"><\/span><\/h3>\n<p>Another interesting metric is to know how much money in tips can the personnel expect depending on the day of the week.<\/p>\n<div class=\"highlight\">\n<pre><code class=\"language-python\" data-lang=\"python\">sns<span>.<\/span>barplot(data<span>=<\/span>tips_df, x<span>=<\/span><span>\"day\"<\/span>, y<span>=<\/span><span>\"tip\"<\/span>, estimator<span>=<\/span>np<span>.<\/span>sum)&#13;\n<\/code><\/pre>\n<\/div>\n<figure class=\"\" data-src=\"https:\/\/thenextweb.com\/post\/how-to-build-beautiful-plots-with-python-and-seaborn\/tips_day_huec708a051e2aeb706158119271e2ac7f_8130_700x0_resize_box_2.png\">\n<figure class=\"post-image post-mediaBleed aligncenter\"><img loading=\"lazy\" decoding=\"async\" class=\"lazy loaded lazy\" alt=\"\" width=\"700\" height=\"489\" src=\"https:\/\/livecodestream.dev\/post\/how-to-build-beautiful-plots-with-python-and-seaborn\/tips_day_huec708a051e2aeb706158119271e2ac7f_8130_700x0_resize_box_2.png\" data-lazy=\"true\"\/><figcaption><a rel=\"nofollow noopener\" target=\"_blank\" href=\"https:\/\/thenextweb.com\/syndication\/2021\/01\/05\/a-beginners-guide-to-data-visualization-with-python-and-seaborn\/#\" data-url=\"https:\/\/twitter.com\/intent\/tweet?url=https%3A%2F%2Fthenextweb.com%2Fsyndication%2F2021%2F01%2F05%2Fa-beginners-guide-to-data-visualization-with-python-and-seaborn%2F&amp;via=thenextweb&amp;related=thenextweb&amp;text=Check out this picture on: Understanding tip percentages per day plot\" data-title=\"Share Understanding tip percentages per day plot on Twitter\" data-width=\"685\" data-height=\"500\" class=\"post-image-share popitup\" title=\"Share Understanding tip percentages per day plot on Twitter\"><i class=\"icon icon--inline icon--twitter--dark\"\/><\/a>Understanding tip percentages per day plot<\/figcaption><\/figure>\n<\/p>\n<\/figure>\n<p>It looks like Friday is a good day to stay home.<\/p>\n<h3 id=\"impact-of-table-size-and-day-on-the-tip\"><span class=\"ez-toc-section\" id=\"Impact_of_table_size_and_day_on_the_tip\"><\/span>Impact of table size and day on the tip<span class=\"ez-toc-section-end\"><\/span><\/h3>\n<p>Sometimes we want to understand how to variables play together to determine output. For example, how do the day of the week and the table size impact the tip percentage?<\/p>\n<p>To draw the next chart we will combine the<span>\u00a0<\/span><code>pivot<\/code><span>\u00a0<\/span>function of pandas to pre-process the information and then draw a heatmap chart.<\/p>\n<div class=\"highlight\">\n<pre><code class=\"language-python\" data-lang=\"python\">pivot <span>=<\/span> tips_df<span>.<\/span>pivot_table(&#13;\n    index<span>=<\/span>[<span>\"day\"<\/span>],&#13;\n    columns<span>=<\/span>[<span>\"size\"<\/span>],&#13;\n    values<span>=<\/span><span>\"tip_percentage\"<\/span>,&#13;\n    aggfunc<span>=<\/span>np<span>.<\/span>average)&#13;\nsns<span>.<\/span>heatmap(pivot)&#13;\n<\/code><\/pre>\n<\/div>\n<figure class=\"\" data-src=\"https:\/\/thenextweb.com\/post\/how-to-build-beautiful-plots-with-python-and-seaborn\/tips_day_size_hu15f48281e45815606a33eb3c6ccd5f81_10084_700x0_resize_box_2.png\">\n<figure class=\"post-image post-mediaBleed aligncenter\"><img loading=\"lazy\" decoding=\"async\" class=\"lazy loaded lazy\" alt=\"\" width=\"700\" height=\"530\" src=\"https:\/\/livecodestream.dev\/post\/how-to-build-beautiful-plots-with-python-and-seaborn\/tips_day_size_hu15f48281e45815606a33eb3c6ccd5f81_10084_700x0_resize_box_2.png\" data-lazy=\"true\"\/><figcaption><a rel=\"nofollow noopener\" target=\"_blank\" href=\"https:\/\/thenextweb.com\/syndication\/2021\/01\/05\/a-beginners-guide-to-data-visualization-with-python-and-seaborn\/#\" data-url=\"https:\/\/twitter.com\/intent\/tweet?url=https%3A%2F%2Fthenextweb.com%2Fsyndication%2F2021%2F01%2F05%2Fa-beginners-guide-to-data-visualization-with-python-and-seaborn%2F&amp;via=thenextweb&amp;related=thenextweb&amp;text=Check out this picture on: Understanding tip percentages per day and table size plot\" data-title=\"Share Understanding tip percentages per day and table size plot on Twitter\" data-width=\"685\" data-height=\"500\" class=\"post-image-share popitup\" title=\"Share Understanding tip percentages per day and table size plot on Twitter\"><i class=\"icon icon--inline icon--twitter--dark\"\/><\/a>Understanding tip percentages per day and table size plot<\/figcaption><\/figure>\n<\/p>\n<\/figure>\n<h2 id=\"conclusion\"><span class=\"ez-toc-section\" id=\"Conclusion\"><\/span>Conclusion<span class=\"ez-toc-section-end\"><\/span><\/h2>\n<p>Of course, there\u2019s much more we can do with<span>\u00a0<\/span><code>seaborn<\/code>, and you can learn more use cases by visiting the<span>\u00a0<\/span><a rel=\"nofollow noopener\" target=\"_blank\" href=\"https:\/\/seaborn.pydata.org\/examples\/index.html\">official documentation<\/a>. I hope that you enjoyed this article as much as I enjoyed writing it.<\/p>\n<hr\/>\n<p><i><span style=\"font-weight: 400;\">This <\/span><\/i><a rel=\"nofollow noopener\" target=\"_blank\" href=\"https:\/\/livecodestream.dev\/post\/how-to-build-beautiful-plots-with-python-and-seaborn\/\"><i><span style=\"font-weight: 400;\">article<\/span><\/i><\/a><i><span style=\"font-weight: 400;\"> was originally published on <\/span><\/i><a rel=\"nofollow noopener\" target=\"_blank\" href=\"https:\/\/livecodestream.dev\/\"><i><span style=\"font-weight: 400;\">Live Code Stream<\/span><\/i><\/a><i><span style=\"font-weight: 400;\"> by <\/span><\/i><a rel=\"nofollow noopener\" target=\"_blank\" href=\"https:\/\/www.linkedin.com\/in\/bajcmartinez\/\"><i><span style=\"font-weight: 400;\">Juan Cruz Martinez<\/span><\/i><\/a><i><span style=\"font-weight: 400;\"> (<a href=\"https:\/\/buradabiliyorum.com\/en\/category\/social-mediaa\/\" data-internallinksmanager029f6b8e52c=\"1\" title=\"Social Media\" target=\"_blank\" rel=\"noopener\">twitter<\/a>: <\/span><\/i><a rel=\"nofollow noopener\" target=\"_blank\" href=\"https:\/\/twitter.com\/bajcmartinez\"><i><span style=\"font-weight: 400;\">@bajcmartinez<\/span><\/i><\/a><i><span style=\"font-weight: 400;\">), founder and publisher of Live Code Stream, entrepreneur, developer, author, speaker, and doer of things.<\/span><\/i><\/p>\n<p><a rel=\"nofollow noopener\" target=\"_blank\" href=\"https:\/\/livecodestream.dev\/subscribe\"><i><span style=\"font-weight: 400;\">Live Code Stream<\/span><\/i><\/a><i><span style=\"font-weight: 400;\"> is also available as a free weekly <a href=\"https:\/\/buradabiliyorum.com\/en\/category\/news\/\" data-internallinksmanager029f6b8e52c=\"2\" title=\"News\" target=\"_blank\" rel=\"noopener\">news<\/a>letter. Sign up for updates on everything related to programming, AI, and computer science in <a href=\"https:\/\/buradabiliyorum.com\/en\/category\/general\/\" data-internallinksmanager029f6b8e52c=\"3\" title=\"General\" target=\"_blank\" rel=\"noopener\">general<\/a>.<\/span><\/i><\/p>\n<p>\u00a0<\/p>\n<\/p><\/div>\n<p><script async src=\"\/\/platform.twitter.com\/widgets.js\" charset=\"utf-8\"><\/script><\/p>\n<blockquote><p><strong><span style=\"color: #ff6600;\">If you liked the article, do not forget to share it with your friends. Follow us on\u00a0<span style=\"color: #ff0000;\"><a style=\"color: #ff0000;\" href=\"https:\/\/news.google.com\/publications\/CAAqBwgKMLG0nwswvr63Aw\" target=\"_blank\" rel=\"nofollow noopener noreferrer\">Google News<\/a><\/span>\u00a0too, click on the star and choose us from your favorites.<\/span><\/strong><\/p><\/blockquote>\n<blockquote>\n<p style=\"text-align: center;\">For forums sites go to <span style=\"color: #ff9900;\"><a style=\"color: #ff9900;\" href=\"https:\/\/forum.buradabiliyorum.com\/\" target=\"_blank\" rel=\"noopener\">Forum.BuradaBiliyorum.Com<\/a><\/span><\/strong>\n<\/p><\/blockquote>\n<blockquote>\n<p style=\"text-align: center;\"><strong>If you want to read more like this article, you can visit our <span style=\"color: #ff9900;\"><a style=\"color: #ff9900;\" href=\"https:\/\/en.buradabiliyorum.com\/technology\/\" target=\"_blank\" rel=\"noopener\">Technology category.<\/a><\/span><\/strong><\/p>\n<\/blockquote>\n<p><span style=\"color: black;\"><a style=\"color: #ff9900;\" href=\"https:\/\/thenextweb.com\/syndication\/2021\/01\/05\/a-beginners-guide-to-data-visualization-with-python-and-seaborn\/\" target=\"_blank\" rel=\"noopener\">Source<\/a><\/span><\/p>\n","protected":false},"excerpt":{"rendered":"<p>&#8220;#A beginner\u2019s guide to data visualization with Python and Seaborn&#8221; Data visualization is a technique that allows data scientists to convert raw data into charts and plots that generate valuable insights. Charts reduce the complexity of the data and make it easier to understand for any user. There are many tools to perform data visualization,&#8230;<\/p>\n","protected":false},"author":1,"featured_media":147685,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"fifu_image_url":"https:\/\/img-cdn.tnwcdn.com\/image\/tnw?filter_last=1&fit=1280,640&url=https:\/\/cdn0.tnwcdn.com\/wp-content\/blogs.dir\/1\/files\/2021\/01\/1-copy-2.jpg&signature=027716e9dbd0772f540badf1d2b0a36f","fifu_image_alt":"","footnotes":""},"categories":[18],"tags":[86847,73821,88582,76627,73308,73706,70759,75431],"class_list":["post-147684","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-technology","tag-data-scientist","tag-developers","tag-graphics","tag-programming-language","tag-programming-tool","tag-python-programming-language","tag-tech","tag-visualization"],"_links":{"self":[{"href":"https:\/\/buradabiliyorum.com\/en\/wp-json\/wp\/v2\/posts\/147684","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/buradabiliyorum.com\/en\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/buradabiliyorum.com\/en\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/buradabiliyorum.com\/en\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/buradabiliyorum.com\/en\/wp-json\/wp\/v2\/comments?post=147684"}],"version-history":[{"count":0,"href":"https:\/\/buradabiliyorum.com\/en\/wp-json\/wp\/v2\/posts\/147684\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/buradabiliyorum.com\/en\/wp-json\/wp\/v2\/media\/147685"}],"wp:attachment":[{"href":"https:\/\/buradabiliyorum.com\/en\/wp-json\/wp\/v2\/media?parent=147684"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/buradabiliyorum.com\/en\/wp-json\/wp\/v2\/categories?post=147684"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/buradabiliyorum.com\/en\/wp-json\/wp\/v2\/tags?post=147684"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}