{"id":79528,"date":"2020-08-05T19:38:14","date_gmt":"2020-08-05T14:08:14","guid":{"rendered":"https:\/\/techvidvan.com\/tutorials\/?p=79528"},"modified":"2020-08-05T19:38:14","modified_gmt":"2020-08-05T14:08:14","slug":"matplotlib-tutorial","status":"publish","type":"post","link":"https:\/\/techvidvan.com\/tutorials\/matplotlib-tutorial\/","title":{"rendered":"Introduction to Matplotlib &#8211; Python Plotting Library"},"content":{"rendered":"<p>This Matplotlib tutorial will help you get your basics right on using <strong>Python<\/strong> for <strong>Data Visualization<\/strong>. This tutorial will help you learn about <strong>plots<\/strong>, <strong>kinds of plot<\/strong>, <strong>subplots<\/strong>, <strong>labels<\/strong>, and much more.<\/p>\n<p><strong>Visual learning<\/strong> has become an integral part of today\u2019s learning process.<\/p>\n<p>Why not? <strong>Human retention<\/strong> is <strong>increased<\/strong> by<strong> 30%<\/strong> through <strong>pictorial representation<\/strong>. Our mind loves to process <strong>characters<\/strong>, <strong>colors<\/strong>, <strong>lines<\/strong>, <strong>boundaries<\/strong>, etc. <strong>right hemisphere<\/strong> of the brain is pretty funky. The<strong> left-brain hemisphere<\/strong> gets a benefit from this when we want to know about the <strong>python plotting library<\/strong>&#8211; <strong>Matplotlib<\/strong>.<\/p>\n<p>Let\u2019s find out.<\/p>\n<h3>Matplotlib Introduction<\/h3>\n<p>Matplotlib is the most <strong>extensively<\/strong> used <strong>Data Visualization library<\/strong> in Python programming. You can generate <strong>plots<\/strong>, <strong>graphs<\/strong>, <strong>bar graphs<\/strong>, <strong>scatter graphs<\/strong>, <strong>histograms<\/strong>, <strong>arrays<\/strong> etc. in a <strong>2D form easily<\/strong>.<\/p>\n<p>Let\u2019s START!<\/p>\n<h4>1. Importing the Library<\/h4>\n<p>To <strong>run<\/strong> the <strong>matplotlib library<\/strong> in our <strong>IDE environment<\/strong>, it is needed to be <strong>imported<\/strong> under the <strong>alias plt<\/strong>.<\/p>\n<p>[ For Beginners, this library has to be<strong> Installed<\/strong> first under<strong> File &gt; Settings &gt; + sign<\/strong> on the <strong>top right<\/strong> of the <strong>window<\/strong> in <strong>Pycharm<\/strong>].<\/p>\n<p><strong>CODE SNIPPET:<\/strong><\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"null\">import matplotlib.pyplot as plt<\/pre>\n<ul>\n<li><strong>plt<\/strong> becomes <strong>handy<\/strong> in the <strong>further code<\/strong> so as to <strong>type less<\/strong> and <strong>reference<\/strong> the <strong>library again<\/strong> and <strong>again<\/strong>.<\/li>\n<\/ul>\n<h4>2. Few Important Functions<\/h4>\n<p>a. Plot() function: Used to plot the <strong>points<\/strong> or <strong>data<\/strong> on the graph.<\/p>\n<p>b. Label([ ]) function: Used to label the <strong>axes ( x and y )<\/strong> on the graph.<\/p>\n<p>c. Title() function: Used to give <strong>heading<\/strong> to the <strong>graph<\/strong>.<\/p>\n<p>d. Legend() function: Used to mention the <strong>data depicted<\/strong> through the <strong>graph<\/strong>.<\/p>\n<p>e. Show() function: Used to display the <strong>generated graph<\/strong>.<\/p>\n<p><a href=\"https:\/\/techvidvan.com\/tutorials\/wp-content\/uploads\/sites\/2\/2020\/08\/Fundamentals-of-Matplotlib.jpg\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-79532\" src=\"https:\/\/techvidvan.com\/tutorials\/wp-content\/uploads\/sites\/2\/2020\/08\/Fundamentals-of-Matplotlib.jpg\" alt=\"Fundamentals of Matplotlib\" width=\"764\" height=\"806\" \/><\/a><\/p>\n<h4>3. Implementing Various Kinds of Graphs<\/h4>\n<h5>a. LINE GRAPHS- plt.plot()<\/h5>\n<p><strong>CODE SNIPPET:<\/strong><\/p>\n<p>Creating line graphs:<\/p>\n<p><strong>#Using Data<\/strong> for <strong>plotting<\/strong>&#8211;<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"null\">x_axis= [1,2,3,4,5]\ncubes=[1,8,27,64,125]\nplt.plot(x_axis,cubes,color=\"purple\",linewidth=3.0)\nplt.title(\"TechVidvan Line Graph\")\nplt.ylabel(\"CUBES OF NUMBERS\")\n<\/pre>\n<p><strong>#To<\/strong> <strong>Display<\/strong> the <strong>graph<\/strong>&#8211;<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"null\">plt.show()<\/pre>\n<p>&nbsp;<\/p>\n<p><a href=\"https:\/\/techvidvan.com\/tutorials\/wp-content\/uploads\/sites\/2\/2020\/08\/Line-Graph-with-Linewidth.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-79533\" src=\"https:\/\/techvidvan.com\/tutorials\/wp-content\/uploads\/sites\/2\/2020\/08\/Line-Graph-with-Linewidth.png\" alt=\"Line Graph with Linewidth\" width=\"1920\" height=\"1030\" \/><\/a><\/p>\n<p><strong>#Line Graphs<\/strong> in <strong>3D presentation<\/strong>:<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"null\">ax=plt.gca(projection=\u20193d\u2019)\nplt.plot(x_axis,cubes)\nplt.title(\u201cTechVidvan 3D Line Graph\u2019\u2019)\nplt.ylabel(\u201cCUBES OF NUMBERS\u201d)\nplt.show(ax)\n<\/pre>\n<ul>\n<li>This is the <strong>default parameter style<\/strong> to plot graphs and these are simply <strong>line graphs<\/strong>.<\/li>\n<li>\u00a0Note that in the <strong>function plt.plot(x, y)<\/strong>, the <strong>first axis<\/strong> we enter would be <strong>shown<\/strong> on the x axis, which is <strong>x_axis<\/strong> for this particular code.<\/li>\n<li>\u00a0Similarly, the <strong>second axis<\/strong> we enter would be shown on the<strong> y axis<\/strong>, which is <strong>cubes<\/strong> for this particular code.<\/li>\n<li><strong>Color<\/strong> gives us the <strong>choice<\/strong> to <strong>represent<\/strong> the <strong>data line graph<\/strong> using <strong>different colors<\/strong> of <strong>choice<\/strong>.<\/li>\n<li><strong>Linewidth<\/strong> determines the <strong>thickness<\/strong> of the <strong>data presenting line<\/strong>.<\/li>\n<li>We <strong>create<\/strong> a <strong>variable ax<\/strong> which takes the value <strong>plt.gca()<\/strong>.<\/li>\n<li><strong>GCA<\/strong> stands for <strong>Get Current axes<\/strong>. It takes the <strong>argument<\/strong> as <strong>projection=\u20193d\u2019<\/strong> which <strong>projects<\/strong> the axes in<strong> 3d form<\/strong>.<\/li>\n<\/ul>\n<p><a href=\"https:\/\/techvidvan.com\/tutorials\/wp-content\/uploads\/sites\/2\/2020\/08\/3D-line-graph.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-79538\" src=\"https:\/\/techvidvan.com\/tutorials\/wp-content\/uploads\/sites\/2\/2020\/08\/3D-line-graph.png\" alt=\"3D line graph\" width=\"1920\" height=\"1030\" \/><\/a><\/p>\n<p>&nbsp;<\/p>\n<h5>b. BAR GRAPHS- plt.bar()<\/h5>\n<ul>\n<li>Under Bar Graphs plotting, it depends on the user whether they want to <strong>display<\/strong> it <strong>vertically(default)<\/strong> or <strong>horizontally<\/strong>.<\/li>\n<\/ul>\n<p><strong>CODE SNIPPET:<\/strong><br \/>\n<strong>#Creating Bar graphs<\/strong>:<\/p>\n<p><strong>#Using Data<\/strong> for <strong>plotting<\/strong>&#8211;<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"null\">age= [10,12,14,16,18]\nheight_in_ft=[5,5.2,5.4,5.6,5.8]\nplt.bar(age,height_in_ft, color=\"red\")\nplt.title(\"TechVidvan Bar Graph\")\nplt.xlabel(\"Age\")\nplt.ylabel(\"Height\")\nplt.legend([\"Average\"])\n<\/pre>\n<p><strong>#To display<\/strong> the <strong>graph<\/strong>&#8211;<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"null\">plt.show()<\/pre>\n<p><a href=\"https:\/\/techvidvan.com\/tutorials\/wp-content\/uploads\/sites\/2\/2020\/08\/Bar-Graph-with-ticks.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-79535\" src=\"https:\/\/techvidvan.com\/tutorials\/wp-content\/uploads\/sites\/2\/2020\/08\/Bar-Graph-with-ticks.png\" alt=\"Bar Graph with ticks()\" width=\"1920\" height=\"1030\" \/><\/a><\/p>\n<p><strong>#For<\/strong> a <strong>horizontal bar graph<\/strong>&#8211;<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"null\">plt.barh(age,height_in_ft,color=\"yellow\")\nplt.title(\"TechVidvan Horizontal Bar Graph\")\nplt.xlabel(\"Height\")\nplt.ylabel(\"Age\")\nplt.xticks(age)\nplt.yticks(height)\n<\/pre>\n<p><strong>#To display<\/strong> the <strong>graph<\/strong>&#8211;<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"null\">plt.show()<\/pre>\n<p><a href=\"https:\/\/techvidvan.com\/tutorials\/wp-content\/uploads\/sites\/2\/2020\/08\/Bar-Graph-Horizontal.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-79534\" src=\"https:\/\/techvidvan.com\/tutorials\/wp-content\/uploads\/sites\/2\/2020\/08\/Bar-Graph-Horizontal.png\" alt=\"\" width=\"1920\" height=\"1030\" \/><\/a><\/p>\n<ul>\n<li>\u00a0<strong>Plt.bar()<\/strong> displays the <strong>graph<\/strong> on a <strong>vertical axis<\/strong>.<\/li>\n<li><strong>Plt.barh()<\/strong> displays the <strong>graph<\/strong> on the <strong>horizontal axis<\/strong>. (Notice the <strong>h<\/strong> for <strong>horizontal<\/strong>).<\/li>\n<li><strong>Plt.xticks()\/yticks()<\/strong> displays the <strong>value<\/strong> of a <strong>particular bar<\/strong> according to its <strong>axes<\/strong>.<\/li>\n<\/ul>\n<h5>c. HISTOGRAMS &#8211; plt.hist()<\/h5>\n<p>An important argument to be used here is <strong>bins<\/strong>. The range for the <strong>whole data set<\/strong> used can be <strong>divided<\/strong> into <strong>equal parts<\/strong> known as <strong>class intervals<\/strong>. This way, we can <strong>combine<\/strong> the <strong>values<\/strong> to show their <strong>repetition<\/strong> or <strong>frequency<\/strong>.<\/p>\n<p><strong>CODE SNIPPET:<\/strong><br \/>\n<strong>#To create<\/strong> a <strong>Histogram<\/strong>:<\/p>\n<p><strong>#Using<\/strong> some <strong>random data<\/strong>&#8211;<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"null\">x= [2,2,2,5,4,3,6,4,2,8,6,4,3,8,9,1,9,6,5,4,3,10,1,3,2,6,4,8,7,5,4,9]\nplt.hist(x,bins=10,color=\"green\")\nplt.title(\"TechVidvan Histogram\")\nplt.xlabel(\"Random Data\")\nplt.ylabel(\"Frequency\")\n<\/pre>\n<p><strong>#To display<\/strong> the <strong>graph<\/strong>&#8211;<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"null\">plt.show()\n<\/pre>\n<h4><a href=\"https:\/\/techvidvan.com\/tutorials\/wp-content\/uploads\/sites\/2\/2020\/08\/Histogram.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-79536\" src=\"https:\/\/techvidvan.com\/tutorials\/wp-content\/uploads\/sites\/2\/2020\/08\/Histogram.png\" alt=\"Histogram in matplotlib\" width=\"1920\" height=\"1030\" \/><\/a><\/h4>\n<h5>d. SCATTER PLOTS &#8211; plt.scatter()<\/h5>\n<p><strong>CODE SNIPPET:<\/strong><\/p>\n<p><strong>#To create<\/strong> <strong>Scatter plots<\/strong>:<\/p>\n<p><strong>#Using Data<\/strong> for <strong>Plotting<\/strong>&#8211;<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"null\">weekdays= [\"Mon\",\"Tue\",\"Wed\",\"Thu\",\"Fri\"]\nworking_hours=[7,8,9,8,7]\nplt.scatter(weekdays,working_hours,s=10,color=\"grey\")\nplt.title(\"TechVidvan Scatter Plot\")\nplt.xlabel(\"Weekdays\")\nplt.ylabel(\"Working Hours of an employee\")\n<\/pre>\n<p><strong>#To display<\/strong> the <strong>graph<\/strong>&#8211;<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"null\">plt.show()<\/pre>\n<p><a href=\"https:\/\/techvidvan.com\/tutorials\/wp-content\/uploads\/sites\/2\/2020\/08\/Scatter-Plot.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-79537\" src=\"https:\/\/techvidvan.com\/tutorials\/wp-content\/uploads\/sites\/2\/2020\/08\/Scatter-Plot.png\" alt=\"Scatter Plot in matplotlib\" width=\"1920\" height=\"1030\" \/><\/a><\/p>\n<p><strong>S <\/strong>allows us to <strong>size<\/strong> how big the <strong>points<\/strong> we want to make on the <strong>graph<\/strong>.<\/p>\n<h5>e. PIE CHARTS &#8211; plt.pie()<\/h5>\n<p><strong>CODE SNIPPET:<\/strong><\/p>\n<p><strong>#To create pie charts<\/strong>:-<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"null\">pencils=[\"HB\",\"2B\",\"3B\",\"4B\"]\nprice_in_rs=[2,3,5,7]\nExplode=[0,0,0,0.1]\nplt.pie(price_in_rs,explode=Explode,labels=pencils,startangle=45)\nplt.title(\"TechVidvan Pie Chart\")<\/pre>\n<p><strong>#To display<\/strong> the <strong>graph<\/strong>&#8211;<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"null\">plt.show()<\/pre>\n<p><a href=\"https:\/\/techvidvan.com\/tutorials\/wp-content\/uploads\/sites\/2\/2020\/08\/Pie-Chart.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-79539\" src=\"https:\/\/techvidvan.com\/tutorials\/wp-content\/uploads\/sites\/2\/2020\/08\/Pie-Chart.png\" alt=\"Pie Chart in matplotlib\" width=\"1920\" height=\"1030\" \/><\/a><\/p>\n<ul>\n<li>Explode gives a <strong>starting point<\/strong> to all the <strong>fractions present<\/strong> for the <strong>pie chart<\/strong>.<\/li>\n<li><strong>Startangle<\/strong> presents the <strong>chart<\/strong> on a certain <strong>angle<\/strong> we want to <strong>display<\/strong> that on.<\/li>\n<\/ul>\n<h5>f. CATEGORIAL PLOTTING<\/h5>\n<p>To depict different kinds of graphs all at once, the<strong> subplot () function<\/strong> is pretty handy. It <strong>creates<\/strong> a <strong>subplot<\/strong> under the main plot like a <strong>small section<\/strong> of its own, and takes the argument to be situated according to the <strong>plot grid<\/strong>.<\/p>\n<p><strong>CODE SNIPPET:<\/strong><br \/>\n<strong>#To display<\/strong> all the <strong>plottings<\/strong> together:<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"null\">plt.figure(figsize=(12,10))\nplt.subplot(131)\nplt.plot(x_axis,cubes,color=\"purple\")\nplt.ylabel(\"CUBES OF NUMBERS\")\nplt.subplot(132)\nplt.bar(age,height_in_ft,color=\"red\")\nplt.xlabel(\"Age\")\nplt.ylabel(\"Height\")\nplt.legend([\"Average\"])\nplt.subplot(133)\nplt.scatter(weekdays,working_hours,color=\"grey\")\nplt.xlabel(\"Weekdays\")\nplt.ylabel(\"Working Hours of an employee\")\n<\/pre>\n<p><strong>#Heading<\/strong> For the <strong>Combination of graphs<\/strong>:<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"null\">plt.suptitle(\"Techvidvan Combination Of Graphs\")\n<\/pre>\n<p><strong>#To save<\/strong> the plots in <strong>png image<\/strong> <strong>format<\/strong>:<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"null\">plt.savefig(\"plot.png\")<\/pre>\n<p><strong>#To display<\/strong> the <strong>graph<\/strong>&#8211;<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"null\">plt.show()<\/pre>\n<p><a href=\"https:\/\/techvidvan.com\/tutorials\/wp-content\/uploads\/sites\/2\/2020\/08\/Combination.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-79540\" src=\"https:\/\/techvidvan.com\/tutorials\/wp-content\/uploads\/sites\/2\/2020\/08\/Combination.png\" alt=\"categorical plotting\" width=\"1920\" height=\"1030\" \/><\/a><\/p>\n<ul>\n<li><strong>Plt.figure()<\/strong>= Used to <strong>add objects<\/strong> of <strong>multiple axes<\/strong> altogether in a <strong>single figure<\/strong>.<\/li>\n<li><strong>Plt.figure(figsize=())<\/strong> = Used to <strong>specify<\/strong> the <strong>width<\/strong> and <strong>height<\/strong> of a figure in <strong>unit inches<\/strong>.<\/li>\n<li><strong>Plt.subplot(p,q,r)<\/strong>= <strong>Divides<\/strong> the <strong>whole figure<\/strong> into an<strong> p*q grid<\/strong> and <strong>places<\/strong> the <strong>created axes<\/strong> in the <strong>position<\/strong> of <strong>r<\/strong>.<\/li>\n<li><strong>Plt.suptitle()<\/strong>= Gives a <strong>centered heading<\/strong> to the <strong>figure<\/strong>.<\/li>\n<\/ul>\n<h5>g. TO SAVE THE PLOTS AS AN IMAGE FILE<\/h5>\n<p><strong>#To save<\/strong> the <strong>plots<\/strong> in<strong> png image format<\/strong>:<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"null\">plt.savefig(\"plot.png\")\n<\/pre>\n<p><strong>#To display<\/strong> the <strong>graph<\/strong>&#8211;<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"null\">plt.show()<\/pre>\n<p><a href=\"https:\/\/techvidvan.com\/tutorials\/wp-content\/uploads\/sites\/2\/2020\/08\/Png-File.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-79541\" src=\"https:\/\/techvidvan.com\/tutorials\/wp-content\/uploads\/sites\/2\/2020\/08\/Png-File.png\" alt=\"Png File\" width=\"1920\" height=\"1030\" \/><\/a><\/p>\n<p>To save a <strong>plot <\/strong>in PNG form, <strong>savefig()<\/strong> function is used in which the <strong>argument<\/strong> we pass is the<strong> type of graph<\/strong> we want to get in the<strong> image format<\/strong> plus the <strong>extension<\/strong> of<strong> .png<\/strong> after it.<\/p>\n<p>Make sure to write this function before the <strong>show ()<\/strong> function for the <strong>flow of executio<\/strong>n the program code follows.<\/p>\n<h3>Conclusion<\/h3>\n<p>Hooray!!<\/p>\n<p>We\u2019ve finally gone through the <strong>Matplotlib library<\/strong> and <strong>how to<\/strong> <strong>use<\/strong> its <strong>various features<\/strong> like <strong>line graphs<\/strong>, <strong>histograms<\/strong>, <strong>pie charts<\/strong>, <strong>scatter plots<\/strong>, and<strong> 3D graphs<\/strong> to make some aesthetically beautiful graphs of our own.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>This Matplotlib tutorial will help you get your basics right on using Python for Data Visualization. This tutorial will help you learn about plots, kinds of plot, subplots, labels, and much more. Visual learning&#46;&#46;&#46;<\/p>\n","protected":false},"author":1,"featured_media":79531,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1053],"tags":[3075,3076,3077,3078],"class_list":["post-79528","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-python","tag-matplotlib","tag-matplotlib-introduction","tag-matplotlib-tutorial","tag-python-plotting-library"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.7 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>Introduction to Matplotlib - Python Plotting Library - TechVidvan<\/title>\n<meta name=\"description\" content=\"This Matplotlib Tutorial will help you in learning introduction to matplotlib, various types of graphs like line graph, bar graph, histograms, scatter plot.\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/techvidvan.com\/tutorials\/matplotlib-tutorial\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Introduction to Matplotlib - Python Plotting Library - TechVidvan\" \/>\n<meta property=\"og:description\" content=\"This Matplotlib Tutorial will help you in learning introduction to matplotlib, various types of graphs like line graph, bar graph, histograms, scatter plot.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/techvidvan.com\/tutorials\/matplotlib-tutorial\/\" \/>\n<meta property=\"og:site_name\" content=\"TechVidvan\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/TechVidvan\/\" \/>\n<meta property=\"article:published_time\" content=\"2020-08-05T14:08:14+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/techvidvan.com\/tutorials\/wp-content\/uploads\/2020\/08\/Matplotlib-Tutorial.jpg\" \/>\n\t<meta property=\"og:image:width\" content=\"1200\" \/>\n\t<meta property=\"og:image:height\" content=\"628\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/jpeg\" \/>\n<meta name=\"author\" content=\"TechVidvan Team\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@vidvantech\" \/>\n<meta name=\"twitter:site\" content=\"@vidvantech\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"TechVidvan Team\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"7 minutes\" \/>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Introduction to Matplotlib - Python Plotting Library - TechVidvan","description":"This Matplotlib Tutorial will help you in learning introduction to matplotlib, various types of graphs like line graph, bar graph, histograms, scatter plot.","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:\/\/techvidvan.com\/tutorials\/matplotlib-tutorial\/","og_locale":"en_US","og_type":"article","og_title":"Introduction to Matplotlib - Python Plotting Library - TechVidvan","og_description":"This Matplotlib Tutorial will help you in learning introduction to matplotlib, various types of graphs like line graph, bar graph, histograms, scatter plot.","og_url":"https:\/\/techvidvan.com\/tutorials\/matplotlib-tutorial\/","og_site_name":"TechVidvan","article_publisher":"https:\/\/www.facebook.com\/TechVidvan\/","article_published_time":"2020-08-05T14:08:14+00:00","og_image":[{"width":1200,"height":628,"url":"https:\/\/techvidvan.com\/tutorials\/wp-content\/uploads\/2020\/08\/Matplotlib-Tutorial.jpg","type":"image\/jpeg"}],"author":"TechVidvan Team","twitter_card":"summary_large_image","twitter_creator":"@vidvantech","twitter_site":"@vidvantech","twitter_misc":{"Written by":"TechVidvan Team","Est. reading time":"7 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/techvidvan.com\/tutorials\/matplotlib-tutorial\/#article","isPartOf":{"@id":"https:\/\/techvidvan.com\/tutorials\/matplotlib-tutorial\/"},"author":{"name":"TechVidvan Team","@id":"https:\/\/techvidvan.com\/tutorials\/#\/schema\/person\/e9c26e74dd3d87421f7ada9433b8cd22"},"headline":"Introduction to Matplotlib &#8211; Python Plotting Library","datePublished":"2020-08-05T14:08:14+00:00","mainEntityOfPage":{"@id":"https:\/\/techvidvan.com\/tutorials\/matplotlib-tutorial\/"},"wordCount":885,"commentCount":0,"publisher":{"@id":"https:\/\/techvidvan.com\/tutorials\/#organization"},"image":{"@id":"https:\/\/techvidvan.com\/tutorials\/matplotlib-tutorial\/#primaryimage"},"thumbnailUrl":"https:\/\/techvidvan.com\/tutorials\/wp-content\/uploads\/2020\/08\/Matplotlib-Tutorial.jpg","keywords":["Matplotlib","matplotlib introduction","Matplotlib tutorial","python plotting library"],"articleSection":["Python Tutorials"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/techvidvan.com\/tutorials\/matplotlib-tutorial\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/techvidvan.com\/tutorials\/matplotlib-tutorial\/","url":"https:\/\/techvidvan.com\/tutorials\/matplotlib-tutorial\/","name":"Introduction to Matplotlib - Python Plotting Library - TechVidvan","isPartOf":{"@id":"https:\/\/techvidvan.com\/tutorials\/#website"},"primaryImageOfPage":{"@id":"https:\/\/techvidvan.com\/tutorials\/matplotlib-tutorial\/#primaryimage"},"image":{"@id":"https:\/\/techvidvan.com\/tutorials\/matplotlib-tutorial\/#primaryimage"},"thumbnailUrl":"https:\/\/techvidvan.com\/tutorials\/wp-content\/uploads\/2020\/08\/Matplotlib-Tutorial.jpg","datePublished":"2020-08-05T14:08:14+00:00","description":"This Matplotlib Tutorial will help you in learning introduction to matplotlib, various types of graphs like line graph, bar graph, histograms, scatter plot.","breadcrumb":{"@id":"https:\/\/techvidvan.com\/tutorials\/matplotlib-tutorial\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/techvidvan.com\/tutorials\/matplotlib-tutorial\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/techvidvan.com\/tutorials\/matplotlib-tutorial\/#primaryimage","url":"https:\/\/techvidvan.com\/tutorials\/wp-content\/uploads\/2020\/08\/Matplotlib-Tutorial.jpg","contentUrl":"https:\/\/techvidvan.com\/tutorials\/wp-content\/uploads\/2020\/08\/Matplotlib-Tutorial.jpg","width":1200,"height":628,"caption":"Matplotlib Tutorial"},{"@type":"BreadcrumbList","@id":"https:\/\/techvidvan.com\/tutorials\/matplotlib-tutorial\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/techvidvan.com\/tutorials\/"},{"@type":"ListItem","position":2,"name":"Introduction to Matplotlib &#8211; Python Plotting Library"}]},{"@type":"WebSite","@id":"https:\/\/techvidvan.com\/tutorials\/#website","url":"https:\/\/techvidvan.com\/tutorials\/","name":"TechVidvan Blogs","description":"","publisher":{"@id":"https:\/\/techvidvan.com\/tutorials\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/techvidvan.com\/tutorials\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/techvidvan.com\/tutorials\/#organization","name":"TechVidvan","url":"https:\/\/techvidvan.com\/tutorials\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/techvidvan.com\/tutorials\/#\/schema\/logo\/image\/","url":"https:\/\/techvidvan.com\/tutorials\/wp-content\/uploads\/2024\/03\/techvidvan-logo-200x50-1.webp","contentUrl":"https:\/\/techvidvan.com\/tutorials\/wp-content\/uploads\/2024\/03\/techvidvan-logo-200x50-1.webp","width":200,"height":50,"caption":"TechVidvan"},"image":{"@id":"https:\/\/techvidvan.com\/tutorials\/#\/schema\/logo\/image\/"},"sameAs":["https:\/\/www.facebook.com\/TechVidvan\/","https:\/\/x.com\/vidvantech"]},{"@type":"Person","@id":"https:\/\/techvidvan.com\/tutorials\/#\/schema\/person\/e9c26e74dd3d87421f7ada9433b8cd22","name":"TechVidvan Team","description":"The TechVidvan Team delivers practical, beginner-friendly tutorials on programming, Java, Python, C++, DSA, AI, ML, data Science, Android, Flutter, MERN, Web Development, and technology. Our experts are here to help you upskill and excel in today\u2019s tech industry."}]}},"amp_enabled":true,"_links":{"self":[{"href":"https:\/\/techvidvan.com\/tutorials\/wp-json\/wp\/v2\/posts\/79528","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/techvidvan.com\/tutorials\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/techvidvan.com\/tutorials\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/techvidvan.com\/tutorials\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/techvidvan.com\/tutorials\/wp-json\/wp\/v2\/comments?post=79528"}],"version-history":[{"count":0,"href":"https:\/\/techvidvan.com\/tutorials\/wp-json\/wp\/v2\/posts\/79528\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/techvidvan.com\/tutorials\/wp-json\/wp\/v2\/media\/79531"}],"wp:attachment":[{"href":"https:\/\/techvidvan.com\/tutorials\/wp-json\/wp\/v2\/media?parent=79528"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/techvidvan.com\/tutorials\/wp-json\/wp\/v2\/categories?post=79528"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/techvidvan.com\/tutorials\/wp-json\/wp\/v2\/tags?post=79528"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}