{"id":1941,"date":"2019-08-08T12:00:00","date_gmt":"2019-08-08T10:00:00","guid":{"rendered":"https:\/\/kindsonthegenius.com\/blog\/plotting-tutorial-in-python-with-matplolib-pyplot-part-2\/"},"modified":"2026-07-05T03:24:14","modified_gmt":"2026-07-05T01:24:14","slug":"plotting-tutorial-in-python-with-matplolib-pyplot-part-2","status":"publish","type":"post","link":"https:\/\/kindsonthegenius.com\/blog\/plotting-tutorial-in-python-with-matplolib-pyplot-part-2\/","title":{"rendered":"Plotting Tutorial in Python with Matplolib.pyplot \u2013 Part 2"},"content":{"rendered":"<p>This is Part 2 of Plotting Tutorial in Python with Matplotlib.pyplot. <a href=\"https:\/\/kindsonthegenius.com\/tempsite\/plotting-tutorial-in-python-with-matplolib-pyplot-part-1\/\">You can find Part 1 here.<\/a><\/p>\n<p>Here, we cover the following<\/p>\n<ol>\n<li><a href=\"#t1\">Example 2 &#8211; Plotting the Heart Curve<\/a><\/li>\n<li><a href=\"#t2\">Example 3 &#8211; The Figure 8 Curve<\/a><\/li>\n<li><a href=\"#t3\">Working with Subplots<\/a><\/li>\n<li><a href=\"#t4\">Working with Scatterplots<\/a><\/li>\n<li><a href=\"#t5\">Working with Histograms<\/a><\/li>\n<li><a href=\"#t6\">Creating a Bar Plot<\/a><\/li>\n<\/ol>\n<p>&nbsp;<\/p>\n<h5><strong id=\"t1\">1. Example 2 &#8211; Plotting the Heart Curve<\/strong><\/h5>\n<p>This is a curve with the shape of a heart! It is based on the formulas below:<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone wp-image-1091 size-full\" src=\"https:\/\/www.kindsonthegenius.com\/wp-content\/uploads\/2020\/09\/Heart-Curve-Functions.jpg\" alt=\"\" width=\"824\" height=\"148\" \/><\/p>\n<p>The Python code for the heart plot is given in the figure below:<\/p>\n<pre style=\"margin: 0; line-height: 125%;\"><span style=\"color: #888888;\"># We plot the line with RGB tuple (red = 1, green = 0.2, blue = 0.5)<\/span>\n<span style=\"color: #888888;\"># and 20pt line width<\/span>\nplt<span style=\"color: #333333;\">.<\/span>plot(x, y, c<span style=\"color: #333333;\">=<\/span><span style=\"background-color: #fff0f0;\">'red'<\/span>, lw<span style=\"color: #333333;\">=<\/span><span style=\"color: #0000dd; font-weight: bold;\">18<\/span>)\n\n<span style=\"color: #888888;\"># Add features to our figure<\/span>\nplt<span style=\"color: #333333;\">.<\/span>title(<span style=\"background-color: #fff0f0;\">'My Heart!'<\/span>)\nplt<span style=\"color: #333333;\">.<\/span>axis(<span style=\"background-color: #fff0f0;\">'equal'<\/span>)\nplt<span style=\"color: #333333;\">.<\/span>axis(<span style=\"background-color: #fff0f0;\">'off'<\/span>)\nplt<span style=\"color: #333333;\">.<\/span>show()\n<\/pre>\n<p>&nbsp;<\/p>\n<p>The output is shown below:<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-medium wp-image-1092\" src=\"https:\/\/www.kindsonthegenius.com\/wp-content\/uploads\/2020\/09\/Heart-Curve-output-300x254.jpg\" alt=\"Heart Curve output\" width=\"300\" height=\"254\" \/><\/p>\n<p>I recommend you try it. Also change up things a bit to see how it appears. For example, change the color, linewidth etc.<\/p>\n<p>&nbsp;<\/p>\n<h5><strong id=\"t2\">2. Example 3 &#8211; The Figure 8 Curve<\/strong><\/h5>\n<p>This is another interesting curve to create. Besides, it is quite easy to work with. It is based on the following trigonometric equations:<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone wp-image-1093 size-full\" src=\"https:\/\/www.kindsonthegenius.com\/wp-content\/uploads\/2020\/09\/Figure-8-Curve.jpg\" alt=\"\" width=\"641\" height=\"154\" \/><\/p>\n<p>The Python code is given below:<\/p>\n<pre style=\"margin: 0; line-height: 125%;\"><span style=\"color: #888888;\"># 8. Example 3 - The Figure 8 Curve<\/span>\nt <span style=\"color: #333333;\">=<\/span> np<span style=\"color: #333333;\">.<\/span>linspace(<span style=\"color: #0000dd; font-weight: bold;\">0<\/span>, <span style=\"color: #0000dd; font-weight: bold;\">2<\/span> <span style=\"color: #333333;\">*<\/span> np<span style=\"color: #333333;\">.<\/span>pi, <span style=\"color: #0000dd; font-weight: bold;\">40<\/span>)\nx <span style=\"color: #333333;\">=<\/span> np<span style=\"color: #333333;\">.<\/span>sin(t)\ny <span style=\"color: #333333;\">=<\/span> np<span style=\"color: #333333;\">.<\/span>sin(t) <span style=\"color: #333333;\">*<\/span> np<span style=\"color: #333333;\">.<\/span>cos(t)\n\n<span style=\"color: #888888;\"># plt.subplot(2,1,1)<\/span>\nplt<span style=\"color: #333333;\">.<\/span>plot(x, y, \n         markersize <span style=\"color: #333333;\">=<\/span> <span style=\"color: #0000dd; font-weight: bold;\">10<\/span>,\n         linewidth <span style=\"color: #333333;\">=<\/span> <span style=\"color: #0000dd; font-weight: bold;\">15<\/span>,\n         color <span style=\"color: #333333;\">=<\/span> <span style=\"background-color: #fff0f0;\">'green'<\/span>,\n        )\n\nplt<span style=\"color: #333333;\">.<\/span>show()\n<\/pre>\n<p>&nbsp;<\/p>\n<p>The output of the code is given below:<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-medium wp-image-1094\" src=\"https:\/\/www.kindsonthegenius.com\/wp-content\/uploads\/2020\/09\/Figure-8-Curve-Output-300x196.jpg\" alt=\"\" width=\"300\" height=\"196\" \/><\/p>\n<p>&nbsp;<\/p>\n<h5><strong id=\"t3\">3. Working with Subplots<\/strong><\/h5>\n<p>Subplots allow you to display two or more plots in a grid form with each curve in its own rectangular plot. The\u00a0<strong>plt.subplot()<\/strong> function takes at least 3 inputs\u00a0<em>n<\/em><em>,\u00a0m<\/em>\u00a0and\u00a0<em>i<\/em>\u00a0and creates a figure with a\u00a0<em>n<\/em><em>\u00a0<\/em>by<em>\u00a0m<\/em> grid of subplots and then sets the\u00a0<em>i<\/em><em>th<\/em> subplot (counting across the rows) as the current plot (ie. current axes object).<\/p>\n<p>Once, you call the subplot function, then the next plot following it is plotted on the particular subplot specified.<\/p>\n<p>Let&#8217;s take and example<\/p>\n<p>We&#8217;ll plot four different curves in 4 subplots. The equations of the curves is given as:<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone wp-image-1095 \" src=\"https:\/\/www.kindsonthegenius.com\/wp-content\/uploads\/2020\/09\/SawTooth-wave.jpg\" alt=\"\" width=\"615\" height=\"238\" \/><\/p>\n<p>The Python code is given below;<\/p>\n<pre style=\"margin: 0; line-height: 125%;\">t <span style=\"color: #333333;\">=<\/span> np<span style=\"color: #333333;\">.<\/span>linspace(<span style=\"color: #0000dd; font-weight: bold;\">0<\/span>,<span style=\"color: #0000dd; font-weight: bold;\">4<\/span>,<span style=\"color: #0000dd; font-weight: bold;\">200<\/span>)\nf1 <span style=\"color: #333333;\">=<\/span> <span style=\"color: #0000dd; font-weight: bold;\">1<\/span><span style=\"color: #333333;\">\/<\/span><span style=\"color: #0000dd; font-weight: bold;\">2<\/span> <span style=\"color: #333333;\">+<\/span> np<span style=\"color: #333333;\">.<\/span>sin(<span style=\"color: #0000dd; font-weight: bold;\">2<\/span> <span style=\"color: #333333;\">*<\/span> np<span style=\"color: #333333;\">.<\/span>pi <span style=\"color: #333333;\">*<\/span> t) <span style=\"color: #333333;\">\/<\/span> np<span style=\"color: #333333;\">.<\/span>pi\nf2 <span style=\"color: #333333;\">=<\/span> f1  <span style=\"color: #333333;\">-<\/span> np<span style=\"color: #333333;\">.<\/span>sin(<span style=\"color: #0000dd; font-weight: bold;\">4<\/span> <span style=\"color: #333333;\">*<\/span> np<span style=\"color: #333333;\">.<\/span>pi <span style=\"color: #333333;\">*<\/span> t) <span style=\"color: #333333;\">\/<\/span> <span style=\"color: #0000dd; font-weight: bold;\">2<\/span> <span style=\"color: #333333;\">*<\/span> np<span style=\"color: #333333;\">.<\/span>pi\nf3 <span style=\"color: #333333;\">=<\/span> f2  <span style=\"color: #333333;\">+<\/span> np<span style=\"color: #333333;\">.<\/span>sin(<span style=\"color: #0000dd; font-weight: bold;\">6<\/span> <span style=\"color: #333333;\">*<\/span> np<span style=\"color: #333333;\">.<\/span>pi <span style=\"color: #333333;\">*<\/span> t) <span style=\"color: #333333;\">\/<\/span> <span style=\"color: #0000dd; font-weight: bold;\">3<\/span> <span style=\"color: #333333;\">*<\/span> np<span style=\"color: #333333;\">.<\/span>pi\nf4 <span style=\"color: #333333;\">=<\/span> f3  <span style=\"color: #333333;\">-<\/span> np<span style=\"color: #333333;\">.<\/span>sin(<span style=\"color: #0000dd; font-weight: bold;\">8<\/span> <span style=\"color: #333333;\">*<\/span> np<span style=\"color: #333333;\">.<\/span>pi <span style=\"color: #333333;\">*<\/span> t) <span style=\"color: #333333;\">\/<\/span> <span style=\"color: #0000dd; font-weight: bold;\">4<\/span> <span style=\"color: #333333;\">*<\/span> np<span style=\"color: #333333;\">.<\/span>pi\n\nplt<span style=\"color: #333333;\">.<\/span>subplot(<span style=\"color: #0000dd; font-weight: bold;\">2<\/span>,<span style=\"color: #0000dd; font-weight: bold;\">2<\/span>,<span style=\"color: #0000dd; font-weight: bold;\">1<\/span>)\nplt<span style=\"color: #333333;\">.<\/span>plot(t, f1)\nplt<span style=\"color: #333333;\">.<\/span>title(<span style=\"background-color: #fff0f0;\">'N = {}'<\/span><span style=\"color: #333333;\">.<\/span>format(<span style=\"color: #0000dd; font-weight: bold;\">1<\/span>))\n\n\nplt<span style=\"color: #333333;\">.<\/span>subplot(<span style=\"color: #0000dd; font-weight: bold;\">2<\/span>,<span style=\"color: #0000dd; font-weight: bold;\">2<\/span>,<span style=\"color: #0000dd; font-weight: bold;\">2<\/span>)\nplt<span style=\"color: #333333;\">.<\/span>plot(t, f2)\nplt<span style=\"color: #333333;\">.<\/span>title(<span style=\"background-color: #fff0f0;\">'N = {}'<\/span><span style=\"color: #333333;\">.<\/span>format(<span style=\"color: #0000dd; font-weight: bold;\">2<\/span>))\n\n\nplt<span style=\"color: #333333;\">.<\/span>subplot(<span style=\"color: #0000dd; font-weight: bold;\">2<\/span>,<span style=\"color: #0000dd; font-weight: bold;\">2<\/span>,<span style=\"color: #0000dd; font-weight: bold;\">3<\/span>)\nplt<span style=\"color: #333333;\">.<\/span>plot(t,f3)\nplt<span style=\"color: #333333;\">.<\/span>title(<span style=\"background-color: #fff0f0;\">'N = {}'<\/span><span style=\"color: #333333;\">.<\/span>format(<span style=\"color: #0000dd; font-weight: bold;\">3<\/span>))\n\n\nplt<span style=\"color: #333333;\">.<\/span>subplot(<span style=\"color: #0000dd; font-weight: bold;\">2<\/span>,<span style=\"color: #0000dd; font-weight: bold;\">2<\/span>,<span style=\"color: #0000dd; font-weight: bold;\">4<\/span>)\nplt<span style=\"color: #333333;\">.<\/span>plot(t, f4)\nplt<span style=\"color: #333333;\">.<\/span>title(<span style=\"background-color: #fff0f0;\">'N = {}'<\/span><span style=\"color: #333333;\">.<\/span>format(<span style=\"color: #0000dd; font-weight: bold;\">4<\/span>))\n\nplt<span style=\"color: #333333;\">.<\/span>tight_layout()\nplt<span style=\"color: #333333;\">.<\/span>show()\n<\/pre>\n<p>&nbsp;<\/p>\n<p>The output of the code is given below:<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone wp-image-1098 size-full\" src=\"https:\/\/www.kindsonthegenius.com\/wp-content\/uploads\/2020\/09\/Subplots.jpg\" alt=\"\" width=\"863\" height=\"551\" \/><\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<h5><strong id=\"t4\">4. Working with Scatterplots<\/strong><\/h5>\n<p>Scatterplots are used for a number of math applications. The code below shows a scatterplot. Most part of the code are explained as comments within the code.<\/p>\n<pre style=\"margin: 0; line-height: 125%;\"><span style=\"color: #888888;\"># Working with Scatter Plot<\/span>\n\n<span style=\"color: #888888;\"># Set the number of dots in the plot<\/span>\nN <span style=\"color: #333333;\">=<\/span> <span style=\"color: #0000dd; font-weight: bold;\">200<\/span>\n\n<span style=\"color: #888888;\"># Create a random x and y cordinates sampled uniformly from 0 to 1<\/span>\nx <span style=\"color: #333333;\">=<\/span> np<span style=\"color: #333333;\">.<\/span>random<span style=\"color: #333333;\">.<\/span>rand(N)\ny <span style=\"color: #333333;\">=<\/span> np<span style=\"color: #333333;\">.<\/span>random<span style=\"color: #333333;\">.<\/span>rand(N)\n\n<span style=\"color: #888888;\"># Create a random array sampled uniformly from [20, 120]<\/span>\n<span style=\"color: #888888;\"># 'size' array is used below to set the size of each dot<\/span>\nsize <span style=\"color: #333333;\">=<\/span> <span style=\"color: #0000dd; font-weight: bold;\">100<\/span> <span style=\"color: #333333;\">*<\/span> np<span style=\"color: #333333;\">.<\/span>random<span style=\"color: #333333;\">.<\/span>rand(N) <span style=\"color: #333333;\">+<\/span> <span style=\"color: #0000dd; font-weight: bold;\">20<\/span>\n\n<span style=\"color: #888888;\"># Create a rondom 4-tuples sampled uniformly from [0 to 1]<\/span>\n\n<span style=\"color: #888888;\"># The colors array is used to set the color of each dot<\/span>\ncolors <span style=\"color: #333333;\">=<\/span> np<span style=\"color: #333333;\">.<\/span>random<span style=\"color: #333333;\">.<\/span>rand(N,<span style=\"color: #0000dd; font-weight: bold;\">4<\/span>)\n\n<span style=\"color: #888888;\"># Create a figure that is of size 12 by 5 and create a scatter plot<\/span>\nplt<span style=\"color: #333333;\">.<\/span>figure(figsize<span style=\"color: #333333;\">=<\/span>(<span style=\"color: #0000dd; font-weight: bold;\">12<\/span>, <span style=\"color: #0000dd; font-weight: bold;\">5<\/span>))\nplt<span style=\"color: #333333;\">.<\/span>scatter(x, y, c<span style=\"color: #333333;\">=<\/span>colors, s <span style=\"color: #333333;\">=<\/span> size)\nplt<span style=\"color: #333333;\">.<\/span>title(<span style=\"background-color: #fff0f0;\">'Scatter Plot'<\/span>)\nplt<span style=\"color: #333333;\">.<\/span>show()\n<\/pre>\n<p>&nbsp;<\/p>\n<p>The output of the scatter plot is shown below<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone wp-image-1100 size-large\" src=\"https:\/\/www.kindsonthegenius.com\/wp-content\/uploads\/2020\/09\/Scatterplot-1024x454.jpg\" alt=\"\" width=\"735\" height=\"326\" \/><\/p>\n<p>&nbsp;<\/p>\n<h5><strong id=\"t5\">5. Working with Histograms<\/strong><\/h5>\n<p>A histogram is a diagram made up of rectangles placed side by side. The area of the rectangles are proportional to the frequency of a variable while the width is equal to the class interval.<\/p>\n<p>The code below displays a histogram.<\/p>\n<p><!-- HTML generated using hilite.me --><\/p>\n<pre style=\"margin: 0; line-height: 125%;\"><span style=\"color: #888888;\"># Working with Histograms<\/span>\nsamples <span style=\"color: #333333;\">=<\/span> np<span style=\"color: #333333;\">.<\/span>random<span style=\"color: #333333;\">.<\/span>randn(<span style=\"color: #0000dd; font-weight: bold;\">10000<\/span>)\nplt<span style=\"color: #333333;\">.<\/span>hist(samples, bins<span style=\"color: #333333;\">=<\/span><span style=\"color: #0000dd; font-weight: bold;\">20<\/span>, \n         density<span style=\"color: #333333;\">=<\/span><span style=\"color: #007020;\">True<\/span>, \n         alpha<span style=\"color: #333333;\">=<\/span><span style=\"color: #6600ee; font-weight: bold;\">0.9<\/span>, \n         color<span style=\"color: #333333;\">=<\/span>(<span style=\"color: #6600ee; font-weight: bold;\">0.1<\/span>, <span style=\"color: #6600ee; font-weight: bold;\">0.8<\/span>, <span style=\"color: #6600ee; font-weight: bold;\">0.1<\/span>)\n        )\nplt<span style=\"color: #333333;\">.<\/span>title(<span style=\"background-color: #fff0f0;\">'Random Samples - Normal Distribution'<\/span>)\nplt<span style=\"color: #333333;\">.<\/span>ylabel(<span style=\"background-color: #fff0f0;\">'Frequency'<\/span>)\nplt<span style=\"color: #333333;\">.<\/span>xlabel(<span style=\"background-color: #fff0f0;\">'Samples'<\/span>)\n\n<span style=\"color: #888888;\">#Plot a red line<\/span>\nx <span style=\"color: #333333;\">=<\/span> np<span style=\"color: #333333;\">.<\/span>linspace(<span style=\"color: #333333;\">-<\/span><span style=\"color: #0000dd; font-weight: bold;\">4<\/span>, <span style=\"color: #0000dd; font-weight: bold;\">4<\/span>, <span style=\"color: #0000dd; font-weight: bold;\">100<\/span>)\ny <span style=\"color: #333333;\">=<\/span> <span style=\"color: #0000dd; font-weight: bold;\">1<\/span><span style=\"color: #333333;\">\/<\/span>(<span style=\"color: #0000dd; font-weight: bold;\">2<\/span><span style=\"color: #333333;\">*<\/span>np<span style=\"color: #333333;\">.<\/span>pi)<span style=\"color: #333333;\">**<\/span><span style=\"color: #6600ee; font-weight: bold;\">0.5<\/span> <span style=\"color: #333333;\">*<\/span> np<span style=\"color: #333333;\">.<\/span>exp(<span style=\"color: #333333;\">-<\/span>x<span style=\"color: #333333;\">**<\/span><span style=\"color: #0000dd; font-weight: bold;\">2<\/span><span style=\"color: #333333;\">\/<\/span><span style=\"color: #0000dd; font-weight: bold;\">2<\/span>)\nplt<span style=\"color: #333333;\">.<\/span>plot(x, y, <span style=\"background-color: #fff0f0;\">'r'<\/span>, alpha <span style=\"color: #333333;\">=<\/span> <span style=\"color: #6600ee; font-weight: bold;\">0.8<\/span>)\nplt<span style=\"color: #333333;\">.<\/span>show()\n<\/pre>\n<p>&nbsp;<\/p>\n<p>The output of the histogram plot is given below<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone wp-image-1099 size-full\" src=\"https:\/\/www.kindsonthegenius.com\/wp-content\/uploads\/2020\/09\/Histogram.jpg\" alt=\"\" width=\"757\" height=\"507\" \/><\/p>\n<p>&nbsp;<\/p>\n<h5><strong id=\"t6\">6. Creating a Bar Plot<\/strong><\/h5>\n<p>A bar plot also called a bar graph or bar chart is used to present a categerical data with rectangular bars along with corresponding heights that is proportional to the values that they represent.<\/p>\n<p>The code below creates a bar chart.<\/p>\n<pre style=\"margin: 0; line-height: 125%;\"><span style=\"color: #888888;\"># Working With Bar Plots<\/span>\nmonths <span style=\"color: #333333;\">=<\/span> <span style=\"color: #007020;\">range<\/span>(<span style=\"color: #0000dd; font-weight: bold;\">1<\/span>,<span style=\"color: #0000dd; font-weight: bold;\">13<\/span>)\nprecipitation <span style=\"color: #333333;\">=<\/span> [<span style=\"color: #6600ee; font-weight: bold;\">88.8<\/span>,<span style=\"color: #6600ee; font-weight: bold;\">118.8<\/span>,<span style=\"color: #6600ee; font-weight: bold;\">201.0<\/span>,<span style=\"color: #6600ee; font-weight: bold;\">126.5<\/span>,<span style=\"color: #6600ee; font-weight: bold;\">102.2<\/span>,<span style=\"color: #6600ee; font-weight: bold;\">46.4<\/span>,<span style=\"color: #6600ee; font-weight: bold;\">40.8<\/span>,<span style=\"color: #6600ee; font-weight: bold;\">21.0<\/span>,<span style=\"color: #6600ee; font-weight: bold;\">29.4<\/span>,<span style=\"color: #6600ee; font-weight: bold;\">104.8<\/span>,<span style=\"color: #6600ee; font-weight: bold;\">192.0<\/span>,<span style=\"color: #6600ee; font-weight: bold;\">160.6<\/span>]\nplt<span style=\"color: #333333;\">.<\/span>bar(months,precipitation,edgecolor<span style=\"color: #333333;\">=<\/span><span style=\"background-color: #fff0f0;\">'red'<\/span>)\n\nplt<span style=\"color: #333333;\">.<\/span>xticks(months)\nplt<span style=\"color: #333333;\">.<\/span>yticks(<span style=\"color: #007020;\">range<\/span>(<span style=\"color: #0000dd; font-weight: bold;\">0<\/span>, <span style=\"color: #0000dd; font-weight: bold;\">300<\/span>, <span style=\"color: #0000dd; font-weight: bold;\">50<\/span>))\nplt<span style=\"color: #333333;\">.<\/span>grid(<span style=\"color: #007020;\">True<\/span>, alpha<span style=\"color: #333333;\">=<\/span><span style=\"color: #6600ee; font-weight: bold;\">0.9<\/span>, \n         linestyle<span style=\"color: #333333;\">=<\/span><span style=\"background-color: #fff0f0;\">'--'<\/span>)\nplt<span style=\"color: #333333;\">.<\/span>title(<span style=\"background-color: #fff0f0;\">'Precipitation in Onitsha, 2015'<\/span>)\nplt<span style=\"color: #333333;\">.<\/span>ylabel(<span style=\"background-color: #fff0f0;\">'Total Precipitation (mm) '<\/span>)\nplt<span style=\"color: #333333;\">.<\/span>xlabel(<span style=\"background-color: #fff0f0;\">'Month'<\/span>)\n\nplt<span style=\"color: #333333;\">.<\/span>show()\n<\/pre>\n<p>&nbsp;<\/p>\n<p>The output of the code is given below:<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone wp-image-1101 size-full\" src=\"https:\/\/www.kindsonthegenius.com\/wp-content\/uploads\/2020\/09\/Bar-Chart.jpg\" alt=\"\" width=\"794\" height=\"524\" \/><\/p>\n<p>If you have come this far, you&#8217;ve done great. I recommend you do it over again with<a href=\"https:\/\/kindsonthegenius.com\/tempsite\/plotting-tutorial-in-python-with-matplolib-pyplot-part-1\/\"> Part 1<\/a> so it becomes clearer.<\/p>\n<p>Feel free to visit my <a href=\"https:\/\/www.youtube.com\/channel\/UCvHgEAcw6VpcOA3864pSr5A\" target=\"_blank\" rel=\"noopener\">Youtube channel<\/a> for more video lessons<\/p>\n","protected":false},"excerpt":{"rendered":"<p>This is Part 2 of Plotting Tutorial in Python with Matplotlib.pyplot. You can find Part 1 here. Here, we cover the following Example 2 &#8211; &hellip; <\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"pagelayer_contact_templates":[],"_pagelayer_content":"","footnotes":""},"categories":[7],"tags":[],"class_list":["post-1941","post","type-post","status-publish","format-standard","hentry","category-python-tutorials"],"_links":{"self":[{"href":"https:\/\/kindsonthegenius.com\/blog\/wp-json\/wp\/v2\/posts\/1941","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/kindsonthegenius.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/kindsonthegenius.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/kindsonthegenius.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/kindsonthegenius.com\/blog\/wp-json\/wp\/v2\/comments?post=1941"}],"version-history":[{"count":1,"href":"https:\/\/kindsonthegenius.com\/blog\/wp-json\/wp\/v2\/posts\/1941\/revisions"}],"predecessor-version":[{"id":2109,"href":"https:\/\/kindsonthegenius.com\/blog\/wp-json\/wp\/v2\/posts\/1941\/revisions\/2109"}],"wp:attachment":[{"href":"https:\/\/kindsonthegenius.com\/blog\/wp-json\/wp\/v2\/media?parent=1941"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/kindsonthegenius.com\/blog\/wp-json\/wp\/v2\/categories?post=1941"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/kindsonthegenius.com\/blog\/wp-json\/wp\/v2\/tags?post=1941"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}