

{"id":145301,"date":"2025-06-13T12:39:12","date_gmt":"2025-06-13T07:09:12","guid":{"rendered":"https:\/\/data-flair.training\/blogs\/?p=145301"},"modified":"2025-06-13T12:39:12","modified_gmt":"2025-06-13T07:09:12","slug":"matplotlib-subplot","status":"publish","type":"post","link":"https:\/\/data-flair.training\/blogs\/matplotlib-subplot\/","title":{"rendered":"Matplotlib Subplot"},"content":{"rendered":"<h3>Program 1<\/h3>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\">import matplotlib.pyplot as mat\r\nx=[0,1,2,3,4,5]\r\ny=[0,1,4,9,16,25]\r\n\r\nx1=[10,20,30,40,50]\r\ny1=[10,30,20,50,40]\r\n\r\nx2=[100,200,300,400,500]\r\ny3=[100,400,300,500,200]\r\n\r\nmat.subplot(3,1,1)\r\nmat.plot(x,y,marker=\"o\",mec='k',mfc='r',ms=10,ls=\"solid\",lw=5,c='b',label='Product1 ')\r\nmat.plot(y1,x1,marker=\"o\",mec='r',mfc='k',ms=10,ls=\"solid\",lw=5,c='g',label='Product 2')\r\nmat.xlabel(\"X-Product\")\r\nmat.xlabel(\"Y Product\")\r\nmat.title(\"Product\")\r\nmat.legend()\r\nmat.subplot(3,1,2)\r\n\r\nmat.plot(x1,y1,marker=\"o\",mec='y',mfc='k',ms=10,ls=\"solid\",lw=5,c='r',label='Sales')\r\nmat.xlabel(\"X-Sales\")\r\nmat.xlabel(\"Y-Sales\")\r\nmat.title(\"Sales\")\r\nmat.legend()\r\nmat.subplot(3,1,3)\r\n\r\nmat.plot(x1,y1,marker=\"o\",mec='y',mfc='k',ms=10,ls=\"solid\",lw=5,c='r',label='Company')\r\nmat.xlabel(\"X-Company\")\r\nmat.xlabel(\"Y-Company\")\r\nmat.title(\"Company\")\r\nmat.legend()\r\nmat.show()<\/pre>\n<p>&nbsp;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Program 1 import matplotlib.pyplot as mat x=[0,1,2,3,4,5] y=[0,1,4,9,16,25] x1=[10,20,30,40,50] y1=[10,30,20,50,40] x2=[100,200,300,400,500] y3=[100,400,300,500,200] mat.subplot(3,1,1) mat.plot(x,y,marker=&#8221;o&#8221;,mec=&#8217;k&#8217;,mfc=&#8217;r&#8217;,ms=10,ls=&#8221;solid&#8221;,lw=5,c=&#8217;b&#8217;,label=&#8217;Product1 &#8216;) mat.plot(y1,x1,marker=&#8221;o&#8221;,mec=&#8217;r&#8217;,mfc=&#8217;k&#8217;,ms=10,ls=&#8221;solid&#8221;,lw=5,c=&#8217;g&#8217;,label=&#8217;Product 2&#8242;) mat.xlabel(&#8220;X-Product&#8221;) mat.xlabel(&#8220;Y Product&#8221;) mat.title(&#8220;Product&#8221;) mat.legend() mat.subplot(3,1,2) mat.plot(x1,y1,marker=&#8221;o&#8221;,mec=&#8217;y&#8217;,mfc=&#8217;k&#8217;,ms=10,ls=&#8221;solid&#8221;,lw=5,c=&#8217;r&#8217;,label=&#8217;Sales&#8217;) mat.xlabel(&#8220;X-Sales&#8221;) mat.xlabel(&#8220;Y-Sales&#8221;) mat.title(&#8220;Sales&#8221;) mat.legend() mat.subplot(3,1,3) mat.plot(x1,y1,marker=&#8221;o&#8221;,mec=&#8217;y&#8217;,mfc=&#8217;k&#8217;,ms=10,ls=&#8221;solid&#8221;,lw=5,c=&#8217;r&#8217;,label=&#8217;Company&#8217;) mat.xlabel(&#8220;X-Company&#8221;) mat.xlabel(&#8220;Y-Company&#8221;) mat.title(&#8220;Company&#8221;) mat.legend()&#46;&#46;&#46;<\/p>\n","protected":false},"author":581,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[27777],"tags":[8601,30289,30286,34398,30303,34400,34399,30302],"class_list":["post-145301","post","type-post","status-publish","format-standard","hentry","category-matplotlib-tutorials","tag-matplotlib","tag-matplotlib-practical","tag-matplotlib-program","tag-matplotlib-program-on-subplot","tag-matplotlib-subplot","tag-matplotlib-subplot-function","tag-subplot-function-in-matplotlib","tag-subplot-in-matplotlib"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v28.0 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>Matplotlib Subplot - DataFlair<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/data-flair.training\/blogs\/matplotlib-subplot\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Matplotlib Subplot - DataFlair\" \/>\n<meta property=\"og:description\" content=\"Program 1 import matplotlib.pyplot as mat x=[0,1,2,3,4,5] y=[0,1,4,9,16,25] x1=[10,20,30,40,50] y1=[10,30,20,50,40] x2=[100,200,300,400,500] y3=[100,400,300,500,200] mat.subplot(3,1,1) mat.plot(x,y,marker=&quot;o&quot;,mec=&#039;k&#039;,mfc=&#039;r&#039;,ms=10,ls=&quot;solid&quot;,lw=5,c=&#039;b&#039;,label=&#039;Product1 &#039;) mat.plot(y1,x1,marker=&quot;o&quot;,mec=&#039;r&#039;,mfc=&#039;k&#039;,ms=10,ls=&quot;solid&quot;,lw=5,c=&#039;g&#039;,label=&#039;Product 2&#039;) mat.xlabel(&quot;X-Product&quot;) mat.xlabel(&quot;Y Product&quot;) mat.title(&quot;Product&quot;) mat.legend() mat.subplot(3,1,2) mat.plot(x1,y1,marker=&quot;o&quot;,mec=&#039;y&#039;,mfc=&#039;k&#039;,ms=10,ls=&quot;solid&quot;,lw=5,c=&#039;r&#039;,label=&#039;Sales&#039;) mat.xlabel(&quot;X-Sales&quot;) mat.xlabel(&quot;Y-Sales&quot;) mat.title(&quot;Sales&quot;) mat.legend() mat.subplot(3,1,3) mat.plot(x1,y1,marker=&quot;o&quot;,mec=&#039;y&#039;,mfc=&#039;k&#039;,ms=10,ls=&quot;solid&quot;,lw=5,c=&#039;r&#039;,label=&#039;Company&#039;) mat.xlabel(&quot;X-Company&quot;) mat.xlabel(&quot;Y-Company&quot;) mat.title(&quot;Company&quot;) mat.legend()&#046;&#046;&#046;\" \/>\n<meta property=\"og:url\" content=\"https:\/\/data-flair.training\/blogs\/matplotlib-subplot\/\" \/>\n<meta property=\"og:site_name\" content=\"DataFlair\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/DataFlairWS\/\" \/>\n<meta property=\"article:published_time\" content=\"2025-06-13T07:09:12+00:00\" \/>\n<meta name=\"author\" content=\"DataFlair Team\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@DataFlairWS\" \/>\n<meta name=\"twitter:site\" content=\"@DataFlairWS\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"DataFlair Team\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"1 minute\" \/>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Matplotlib Subplot - DataFlair","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:\/\/data-flair.training\/blogs\/matplotlib-subplot\/","og_locale":"en_US","og_type":"article","og_title":"Matplotlib Subplot - DataFlair","og_description":"Program 1 import matplotlib.pyplot as mat x=[0,1,2,3,4,5] y=[0,1,4,9,16,25] x1=[10,20,30,40,50] y1=[10,30,20,50,40] x2=[100,200,300,400,500] y3=[100,400,300,500,200] mat.subplot(3,1,1) mat.plot(x,y,marker=\"o\",mec='k',mfc='r',ms=10,ls=\"solid\",lw=5,c='b',label='Product1 ') mat.plot(y1,x1,marker=\"o\",mec='r',mfc='k',ms=10,ls=\"solid\",lw=5,c='g',label='Product 2') mat.xlabel(\"X-Product\") mat.xlabel(\"Y Product\") mat.title(\"Product\") mat.legend() mat.subplot(3,1,2) mat.plot(x1,y1,marker=\"o\",mec='y',mfc='k',ms=10,ls=\"solid\",lw=5,c='r',label='Sales') mat.xlabel(\"X-Sales\") mat.xlabel(\"Y-Sales\") mat.title(\"Sales\") mat.legend() mat.subplot(3,1,3) mat.plot(x1,y1,marker=\"o\",mec='y',mfc='k',ms=10,ls=\"solid\",lw=5,c='r',label='Company') mat.xlabel(\"X-Company\") mat.xlabel(\"Y-Company\") mat.title(\"Company\") mat.legend()&#46;&#46;&#46;","og_url":"https:\/\/data-flair.training\/blogs\/matplotlib-subplot\/","og_site_name":"DataFlair","article_publisher":"https:\/\/www.facebook.com\/DataFlairWS\/","article_published_time":"2025-06-13T07:09:12+00:00","author":"DataFlair Team","twitter_card":"summary_large_image","twitter_creator":"@DataFlairWS","twitter_site":"@DataFlairWS","twitter_misc":{"Written by":"DataFlair Team","Est. reading time":"1 minute"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/data-flair.training\/blogs\/matplotlib-subplot\/#article","isPartOf":{"@id":"https:\/\/data-flair.training\/blogs\/matplotlib-subplot\/"},"author":{"name":"DataFlair Team","@id":"https:\/\/data-flair.training\/blogs\/#\/schema\/person\/c187795dc82ab948373cca526df7c445"},"headline":"Matplotlib Subplot","datePublished":"2025-06-13T07:09:12+00:00","mainEntityOfPage":{"@id":"https:\/\/data-flair.training\/blogs\/matplotlib-subplot\/"},"wordCount":4,"commentCount":0,"publisher":{"@id":"https:\/\/data-flair.training\/blogs\/#organization"},"keywords":["Matplotlib","matplotlib practical","matplotlib program","matplotlib program on subplot","matplotlib subplot","matplotlib subplot function","subplot function in matplotlib","subplot in matplotlib"],"articleSection":["Matplotlib Tutorials"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/data-flair.training\/blogs\/matplotlib-subplot\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/data-flair.training\/blogs\/matplotlib-subplot\/","url":"https:\/\/data-flair.training\/blogs\/matplotlib-subplot\/","name":"Matplotlib Subplot - DataFlair","isPartOf":{"@id":"https:\/\/data-flair.training\/blogs\/#website"},"datePublished":"2025-06-13T07:09:12+00:00","breadcrumb":{"@id":"https:\/\/data-flair.training\/blogs\/matplotlib-subplot\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/data-flair.training\/blogs\/matplotlib-subplot\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/data-flair.training\/blogs\/matplotlib-subplot\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Blog Home","item":"https:\/\/data-flair.training\/blogs\/"},{"@type":"ListItem","position":2,"name":"Matplotlib Tutorials","item":"https:\/\/data-flair.training\/blogs\/category\/matplotlib-tutorials\/"},{"@type":"ListItem","position":3,"name":"Matplotlib Subplot"}]},{"@type":"WebSite","@id":"https:\/\/data-flair.training\/blogs\/#website","url":"https:\/\/data-flair.training\/blogs\/","name":"DataFlair","description":"Learn Today. Lead Tomorrow.","publisher":{"@id":"https:\/\/data-flair.training\/blogs\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/data-flair.training\/blogs\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/data-flair.training\/blogs\/#organization","name":"DataFlair","url":"https:\/\/data-flair.training\/blogs\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/data-flair.training\/blogs\/#\/schema\/logo\/image\/","url":"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2016\/07\/Data-Flair.png","contentUrl":"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2016\/07\/Data-Flair.png","width":106,"height":48,"caption":"DataFlair"},"image":{"@id":"https:\/\/data-flair.training\/blogs\/#\/schema\/logo\/image\/"},"sameAs":["https:\/\/www.facebook.com\/DataFlairWS\/","https:\/\/x.com\/DataFlairWS","https:\/\/www.linkedin.com\/company\/dataflair-web-services-pvt-ltd\/","https:\/\/www.youtube.com\/user\/DataFlairWS"]},{"@type":"Person","@id":"https:\/\/data-flair.training\/blogs\/#\/schema\/person\/c187795dc82ab948373cca526df7c445","name":"DataFlair Team","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/secure.gravatar.com\/avatar\/2302ebc438084d2f1f993edc1996a0aae01332e81f3227cba8df0c48ec010ca4?s=96&d=mm&r=g","url":"https:\/\/secure.gravatar.com\/avatar\/2302ebc438084d2f1f993edc1996a0aae01332e81f3227cba8df0c48ec010ca4?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/2302ebc438084d2f1f993edc1996a0aae01332e81f3227cba8df0c48ec010ca4?s=96&d=mm&r=g","caption":"DataFlair Team"},"description":"DataFlair Team provides high-impact content on programming, Java, Python, C++, DSA, AI, ML, data Science, Android, Flutter, MERN, Web Development, and technology. We make complex concepts easy to grasp, helping learners of all levels succeed in their tech careers.","url":"https:\/\/data-flair.training\/blogs\/author\/dfteam6\/"}]}},"amp_enabled":true,"_links":{"self":[{"href":"https:\/\/data-flair.training\/blogs\/wp-json\/wp\/v2\/posts\/145301","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/data-flair.training\/blogs\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/data-flair.training\/blogs\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/data-flair.training\/blogs\/wp-json\/wp\/v2\/users\/581"}],"replies":[{"embeddable":true,"href":"https:\/\/data-flair.training\/blogs\/wp-json\/wp\/v2\/comments?post=145301"}],"version-history":[{"count":2,"href":"https:\/\/data-flair.training\/blogs\/wp-json\/wp\/v2\/posts\/145301\/revisions"}],"predecessor-version":[{"id":145311,"href":"https:\/\/data-flair.training\/blogs\/wp-json\/wp\/v2\/posts\/145301\/revisions\/145311"}],"wp:attachment":[{"href":"https:\/\/data-flair.training\/blogs\/wp-json\/wp\/v2\/media?parent=145301"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/data-flair.training\/blogs\/wp-json\/wp\/v2\/categories?post=145301"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/data-flair.training\/blogs\/wp-json\/wp\/v2\/tags?post=145301"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}