<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	
	xmlns:georss="http://www.georss.org/georss"
	xmlns:geo="http://www.w3.org/2003/01/geo/wgs84_pos#"
	>

<channel>
	<title>Python Matplotlib Tutorial - Indian AI Production</title>
	<atom:link href="https://indianaiproduction.com/python-matplotlib-tutorial-mastery-in-matplotlib-library/feed/" rel="self" type="application/rss+xml" />
	<link>https://indianaiproduction.com/python-matplotlib-tutorial-mastery-in-matplotlib-library/</link>
	<description>Artificial Intelligence Education Free for Everyone</description>
	<lastBuildDate>Wed, 11 Sep 2019 07:17:39 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	

<image>
	<url>https://i0.wp.com/indianaiproduction.com/wp-content/uploads/2019/06/Channel-logo-in-circle-473-x-472-px.png?fit=32%2C32&#038;ssl=1</url>
	<title>Python Matplotlib Tutorial - Indian AI Production</title>
	<link>https://indianaiproduction.com/python-matplotlib-tutorial-mastery-in-matplotlib-library/</link>
	<width>32</width>
	<height>32</height>
</image> 
<site xmlns="com-wordpress:feed-additions:1">163118462</site>	<item>
		<title>Matplotlib imshow &#8211; Read &#038; Show image using imread() &#038; plt.imshow()</title>
		<link>https://indianaiproduction.com/matplotlib-imshow/</link>
					<comments>https://indianaiproduction.com/matplotlib-imshow/#respond</comments>
		
		<dc:creator><![CDATA[Indian AI Production]]></dc:creator>
		<pubDate>Wed, 31 Jul 2019 11:12:35 +0000</pubDate>
				<category><![CDATA[Python Matplotlib Tutorial]]></category>
		<category><![CDATA[imshow]]></category>
		<category><![CDATA[matplotlib imread]]></category>
		<category><![CDATA[matplotlib imshow]]></category>
		<category><![CDATA[matplotlib imshow size]]></category>
		<category><![CDATA[plt imshow cmap]]></category>
		<category><![CDATA[plt.colorbar()]]></category>
		<category><![CDATA[plt.imshow()]]></category>
		<category><![CDATA[python display image on screen]]></category>
		<category><![CDATA[python show image]]></category>
		<guid isPermaLink="false">https://indianaiproduction.com/?p=873</guid>

					<description><![CDATA[<p>If you worry about, how to read and show an image using the matplotlib library then here you will get a solution for your problem. Along with that, you will be got a bonus. The matplotlib imshow() function helps to show the image. But plt.imshow() didn&#8217;t work without mpimg.imread() function which is belongs to matplotlib.image &#8230;</p>
<p class="read-more"> <a class="" href="https://indianaiproduction.com/matplotlib-imshow/"> <span class="screen-reader-text">Matplotlib imshow &#8211; Read &#038; Show image using imread() &#038; plt.imshow()</span> Read More &#187;</a></p>
<p>The post <a rel="nofollow" href="https://indianaiproduction.com/matplotlib-imshow/">Matplotlib imshow &#8211; Read &#038; Show image using imread() &#038; plt.imshow()</a> appeared first on <a rel="nofollow" href="https://indianaiproduction.com">Indian AI Production</a>.</p>
]]></description>
										<content:encoded><![CDATA[
<p>If you worry about, how to read and show an image using the matplotlib library then here you will get a solution for your problem. Along with that, you will be got a bonus. The <strong>matplotlib imshow()</strong> function helps to show the image.</p>



<p>But <strong>plt.imshow()</strong> didn&#8217;t work without <strong>mpimg.imread()</strong> function which is belongs to matplotlib.image module.  So lets start practical.</p>



<h3 class="wp-block-heading">Import Libraries</h3>


<div class="wp-block-syntaxhighlighter-code "><pre class="brush: python; title: ; notranslate">
import matplotlib.pyplot as plt
import matplotlib.image as mpimg # image module for image reading
</pre></div>


<h3 class="wp-block-heading">Reading Image</h3>



<p>Here, we use mpimg.imread() method. Which belongs to the matplotlib image module.</p>


<div class="wp-block-syntaxhighlighter-code "><pre class="brush: python; title: ; notranslate">
img = mpimg.imread(&quot;pie_char.png&quot;) # give addres of image location
print(img)
</pre></div>


<p><strong>Output</strong> <strong>&gt;&gt;&gt;</strong></p>


<div class="wp-block-syntaxhighlighter-code "><pre class="brush: python; title: ; notranslate">
&#x5B;&#x5B;&#x5B;1., 1., 1., 1.],
        &#x5B;1., 1., 1., 1.],
        &#x5B;1., 1., 1., 1.],
        ...,
        &#x5B;1., 1., 1., 1.],
        &#x5B;1., 1., 1., 1.],
        &#x5B;1., 1., 1., 1.]],

       &#x5B;&#x5B;1., 1., 1., 1.],
        &#x5B;1., 1., 1., 1.],
        &#x5B;1., 1., 1., 1.],
        ...,
        &#x5B;1., 1., 1., 1.],
        &#x5B;1., 1., 1., 1.],
        &#x5B;1., 1., 1., 1.]],

       &#x5B;&#x5B;1., 1., 1., 1.],
        &#x5B;1., 1., 1., 1.],
        &#x5B;1., 1., 1., 1.],
        ...,
        &#x5B;1., 1., 1., 1.],
        &#x5B;1., 1., 1., 1.],
        &#x5B;1., 1., 1., 1.]],

       ...,

       &#x5B;&#x5B;1., 1., 1., 1.],
        &#x5B;1., 1., 1., 1.],
        &#x5B;1., 1., 1., 1.],
        ...,
        &#x5B;1., 1., 1., 1.],
        &#x5B;1., 1., 1., 1.],
        &#x5B;1., 1., 1., 1.]],

       &#x5B;&#x5B;1., 1., 1., 1.],
        &#x5B;1., 1., 1., 1.],
        &#x5B;1., 1., 1., 1.],
        ...,
        &#x5B;1., 1., 1., 1.],
        &#x5B;1., 1., 1., 1.],
        &#x5B;1., 1., 1., 1.]],

       &#x5B;&#x5B;1., 1., 1., 1.],
        &#x5B;1., 1., 1., 1.],
        &#x5B;1., 1., 1., 1.],
        ...,
        &#x5B;1., 1., 1., 1.],
        &#x5B;1., 1., 1., 1.],
        &#x5B;1., 1., 1., 1.]]], dtype=float32)
</pre></div>


<p>Above you can see, when we call <strong>img</strong> then got numpy array but how. because mpimg.imread() function read <strong>pie_char.png</strong> image and store in <a href="https://indianaiproduction.com/python-numpy-array/" target="_blank" rel="noopener noreferrer">numpy array</a> format.</p>



<p>Get more information about <strong>img</strong>.</p>


<div class="wp-block-syntaxhighlighter-code "><pre class="brush: python; title: ; notranslate">
print(&quot;Data type of img &gt; &quot;, type(img))
print(&quot;Shape of img &gt; &quot;, img.shape)
print(&quot;Dimention of img &gt; &quot;,img.ndim)
</pre></div>


<p><strong>output &gt;&gt;&gt;</strong></p>


<div class="wp-block-syntaxhighlighter-code "><pre class="brush: python; title: ; notranslate">
Data type of img &gt; numpy.ndarray

Shape of img &gt; (288, 432, 4)

Dimention of img &gt; 3
</pre></div>


<h3 class="wp-block-heading">Show  Image  using matplotlib imshow</h3>



<p>It&#8217;s time to show an image using a read dataset.</p>



<p>To show an image, use plt.imshow() function.</p>



<p><span style="color: #ff0000;"><strong>Syntax :<span style="color: #800000;">plt.imshow(</span></strong></span><br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #008000;"><strong>X,&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;</strong></span><br><span style="color: #008000;"><strong>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;cmap=None,</strong></span><br><span style="color: #008000;"><strong>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;norm=None,</strong></span><br><span style="color: #008000;"><strong>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;aspect=None,</strong></span><br><span style="color: #008000;"><strong>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;interpolation=None,</strong></span><br><span style="color: #008000;"><strong>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;alpha=None,</strong></span><br><span style="color: #008000;"><strong>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;vmin=None,</strong></span><br><span style="color: #008000;"><strong>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;vmax=None,</strong></span><br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #008000;"><strong> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;origin=None,</strong></span><br><span style="color: #008000;"><strong>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;extent=None,</strong></span><br><span style="color: #008000;"><strong>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;shape=None,</strong></span><br><span style="color: #008000;"><strong>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;filternorm=1,</strong></span><br><span style="color: #008000;"><strong>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;filterrad=4.0,</strong></span><br><span style="color: #008000;"><strong>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;imlim=None,</strong></span><br><span style="color: #008000;"><strong>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;resample=None,</strong></span><br><span style="color: #008000;"><strong>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;url=None,</strong></span><br><span style="color: #008000;"><strong>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;*,</strong></span><br><span style="color: #008000;"><strong>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;data=None,</strong></span><br><span style="color: #008000;"><strong>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;**kwargs,</strong></span><br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #800000;"><strong>)</strong></span></p>


<div class="wp-block-syntaxhighlighter-code "><pre class="brush: python; title: ; notranslate">
plt.imshow(img)
plt.show()
</pre></div>


<p><strong>Output &gt;&gt;&gt;</strong></p>



<ul class="wp-block-gallery aligncenter columns-1 is-cropped wp-block-gallery-1 is-layout-flex"><li class="blocks-gallery-item"><figure><img decoding="async" width="370" height="252" src="https://i0.wp.com/indianaiproduction.com/wp-content/uploads/2019/07/matplotlib-imshow-pi_chart-1-min.png?resize=370%2C252&#038;ssl=1" alt="matplotlib imshow - pi_chart " data-id="887" data-link="https://indianaiproduction.com/?attachment_id=887" class="wp-image-887" srcset="https://i0.wp.com/indianaiproduction.com/wp-content/uploads/2019/07/matplotlib-imshow-pi_chart-1-min.png?w=370&amp;ssl=1 370w, https://i0.wp.com/indianaiproduction.com/wp-content/uploads/2019/07/matplotlib-imshow-pi_chart-1-min.png?resize=300%2C204&amp;ssl=1 300w" sizes="(max-width: 370px) 100vw, 370px" data-recalc-dims="1" /></figure></li></ul>



<p>Now, removing the axis and increase figure size and then show the same image.</p>


<div class="wp-block-syntaxhighlighter-code "><pre class="brush: python; title: ; notranslate">
plt.figure(figsize=(16,9))
plt.axis(&quot;off&quot;)
plt.imshow(img)
plt.show()
</pre></div>


<p><strong>Output &gt;&gt;&gt;</strong></p>



<ul class="wp-block-gallery columns-1 is-cropped wp-block-gallery-3 is-layout-flex"><li class="blocks-gallery-item"><figure><img decoding="async" width="774" height="523" src="https://i0.wp.com/indianaiproduction.com/wp-content/uploads/2019/07/matplotlib-imshow-pi_chart-2-min.png?resize=774%2C523&#038;ssl=1" alt="matplotlib imshow - pi_chart " data-id="888" data-link="https://indianaiproduction.com/?attachment_id=888" class="wp-image-888" srcset="https://i0.wp.com/indianaiproduction.com/wp-content/uploads/2019/07/matplotlib-imshow-pi_chart-2-min.png?w=774&amp;ssl=1 774w, https://i0.wp.com/indianaiproduction.com/wp-content/uploads/2019/07/matplotlib-imshow-pi_chart-2-min.png?resize=300%2C203&amp;ssl=1 300w, https://i0.wp.com/indianaiproduction.com/wp-content/uploads/2019/07/matplotlib-imshow-pi_chart-2-min.png?resize=768%2C519&amp;ssl=1 768w" sizes="(max-width: 774px) 100vw, 774px" data-recalc-dims="1" /></figure></li></ul>



<p>Now, it looks great but can we add it&#8217;s a color bar. Yes, using <strong>plt.colorbar() </strong>function.</p>



<h3 class="wp-block-heading">Show Image with Colorbar</h3>


<div class="wp-block-syntaxhighlighter-code "><pre class="brush: python; title: ; notranslate">
plt.figure(figsize=(16,9))
plt.axis(&quot;off&quot;)
plt.imshow(img)
plt.colorbar() # Show color bar of above image
plt.show()
</pre></div>


<p><strong>Output &gt;&gt;&gt;</strong></p>



<p><img fetchpriority="high" decoding="async" class="aligncenter wp-image-889 size-full" src="https://i0.wp.com/indianaiproduction.com/wp-content/uploads/2019/07/matplotlib-imshow-pi_chart-with-color-3-min.png?resize=695%2C518&#038;ssl=1" alt="matplotlib imshow - pi_chart with color" width="695" height="518" srcset="https://i0.wp.com/indianaiproduction.com/wp-content/uploads/2019/07/matplotlib-imshow-pi_chart-with-color-3-min.png?w=695&amp;ssl=1 695w, https://i0.wp.com/indianaiproduction.com/wp-content/uploads/2019/07/matplotlib-imshow-pi_chart-with-color-3-min.png?resize=300%2C224&amp;ssl=1 300w" sizes="(max-width: 695px) 100vw, 695px" data-recalc-dims="1" /></p>



<h3 class="wp-block-heading">Show Image with cmap Parameter</h3>



<p>Let&#8217;s play with <strong>plt.imshow()</strong> functions parameter. Here use cmap means color map to show a single-channel image in a different color.</p>


<div class="wp-block-syntaxhighlighter-code "><pre class="brush: python; title: ; notranslate">
single_channel = img&#x5B;:,:,1] # get single channel data from img
plt.figure(figsize=(16,9))
plt.axis(&quot;off&quot;)
plt.imshow(single_channel, cmap = &quot;hot&quot;) # show image with hot color map
plt.colorbar()
plt.show()
</pre></div>


<p><strong>Output &gt;&gt;&gt;</strong></p>



<ul class="wp-block-gallery columns-1 is-cropped wp-block-gallery-5 is-layout-flex"><li class="blocks-gallery-item"><figure><img loading="lazy" decoding="async" width="846" height="517" src="https://i0.wp.com/indianaiproduction.com/wp-content/uploads/2019/07/matplotlib-imshow-pie_chart-4-min.png?resize=846%2C517&#038;ssl=1" alt="matplotlib imshow - pie_chart" data-id="890" data-link="https://indianaiproduction.com/?attachment_id=890" class="wp-image-890" srcset="https://i0.wp.com/indianaiproduction.com/wp-content/uploads/2019/07/matplotlib-imshow-pie_chart-4-min.png?w=846&amp;ssl=1 846w, https://i0.wp.com/indianaiproduction.com/wp-content/uploads/2019/07/matplotlib-imshow-pie_chart-4-min.png?resize=300%2C183&amp;ssl=1 300w, https://i0.wp.com/indianaiproduction.com/wp-content/uploads/2019/07/matplotlib-imshow-pie_chart-4-min.png?resize=768%2C469&amp;ssl=1 768w" sizes="(max-width: 846px) 100vw, 846px" data-recalc-dims="1" /></figure></li></ul>



<p>If you want to show an image using a folder path, then follow the below code.</p>


<div class="wp-block-syntaxhighlighter-code "><pre class="brush: python; title: ; notranslate">
img2 = mpimg.imread(&quot;D:\\Private\\Wallpapers\\Pixels\\automobile-beautiful-car-1226458.jpg&quot;)
plt.figure(figsize=(16,9))
plt.axis(&quot;off&quot;)
plt.imshow(img2)
plt.colorbar()
plt.show()
</pre></div>


<p><strong>Output &gt;&gt;&gt;</strong></p>



<figure class="wp-block-image"><img loading="lazy" decoding="async" width="854" height="524" src="https://i0.wp.com/indianaiproduction.com/wp-content/uploads/2019/07/matplotlib-imshow-model-5-min.png?resize=854%2C524&#038;ssl=1" alt="matplotlib-imshow-model" class="wp-image-901" srcset="https://i0.wp.com/indianaiproduction.com/wp-content/uploads/2019/07/matplotlib-imshow-model-5-min.png?w=854&amp;ssl=1 854w, https://i0.wp.com/indianaiproduction.com/wp-content/uploads/2019/07/matplotlib-imshow-model-5-min.png?resize=300%2C184&amp;ssl=1 300w, https://i0.wp.com/indianaiproduction.com/wp-content/uploads/2019/07/matplotlib-imshow-model-5-min.png?resize=768%2C471&amp;ssl=1 768w" sizes="(max-width: 854px) 100vw, 854px" data-recalc-dims="1" /></figure>



<p>If, you don&#8217;t want to show color bar then remove 5&#8217;th no line.</p>



<p>Model image shows with <strong>hot </strong>color maps (cmap).</p>


<div class="wp-block-syntaxhighlighter-code "><pre class="brush: python; title: ; notranslate">
single_channel2_img = img2&#x5B;:,:,1]
plt.figure(figsize=(16,9))
plt.axis(&quot;off&quot;)
plt.imshow(single_channel2_img, cmap=&quot;hot&quot;)
plt.colorbar()
plt.savefig(&quot;model_hot.png&quot;)
plt.show()
</pre></div>


<figure class="wp-block-image"><img loading="lazy" decoding="async" width="854" height="524" src="https://i0.wp.com/indianaiproduction.com/wp-content/uploads/2019/07/matplotlib-imshow-model-with-hot-cmap-6-min.png?resize=854%2C524&#038;ssl=1" alt="matplotlib imshow - model with hot cmap" class="wp-image-892" srcset="https://i0.wp.com/indianaiproduction.com/wp-content/uploads/2019/07/matplotlib-imshow-model-with-hot-cmap-6-min.png?w=854&amp;ssl=1 854w, https://i0.wp.com/indianaiproduction.com/wp-content/uploads/2019/07/matplotlib-imshow-model-with-hot-cmap-6-min.png?resize=300%2C184&amp;ssl=1 300w, https://i0.wp.com/indianaiproduction.com/wp-content/uploads/2019/07/matplotlib-imshow-model-with-hot-cmap-6-min.png?resize=768%2C471&amp;ssl=1 768w" sizes="(max-width: 854px) 100vw, 854px" data-recalc-dims="1" /></figure>



<p> Model image shows with <strong>nipy_spectral </strong>color maps (cmap). </p>



<figure class="wp-block-image"><img loading="lazy" decoding="async" width="854" height="524" src="https://i0.wp.com/indianaiproduction.com/wp-content/uploads/2019/07/matplotlib-imshow-modelwith-nipy_spectral-min.png?resize=854%2C524&#038;ssl=1" alt="matplotlib imshow - model with nipy_spectral" class="wp-image-893" srcset="https://i0.wp.com/indianaiproduction.com/wp-content/uploads/2019/07/matplotlib-imshow-modelwith-nipy_spectral-min.png?w=854&amp;ssl=1 854w, https://i0.wp.com/indianaiproduction.com/wp-content/uploads/2019/07/matplotlib-imshow-modelwith-nipy_spectral-min.png?resize=300%2C184&amp;ssl=1 300w, https://i0.wp.com/indianaiproduction.com/wp-content/uploads/2019/07/matplotlib-imshow-modelwith-nipy_spectral-min.png?resize=768%2C471&amp;ssl=1 768w" sizes="(max-width: 854px) 100vw, 854px" data-recalc-dims="1" /></figure>



<p>If we will generate an image with all cmaps then it takes more time. So for that follow the below code.</p>



<p>Below code get <strong>cmaps</strong> name as a string and split all cmap name as a single item of a list <strong>cmap_name_list </strong></p>


<div class="wp-block-syntaxhighlighter-code "><pre class="brush: python; title: ; notranslate">
cmap = &quot;&quot;&quot;Accent, Accent_r, Blues, Blues_r, BrBG, BrBG_r, BuGn, BuGn_r, BuPu, BuPu_r, CMRmap, CMRmap_r, Dark2, Dark2_r, GnBu, GnBu_r, Greens, Greens_r, Greys, Greys_r, OrRd, OrRd_r, Oranges, Oranges_r, PRGn, PRGn_r, Paired, Paired_r, Pastel1, Pastel1_r, Pastel2, Pastel2_r, PiYG, PiYG_r, PuBu, PuBuGn, PuBuGn_r, PuBu_r, PuOr, PuOr_r, PuRd, PuRd_r, Purples, Purples_r, RdBu, RdBu_r, RdGy, RdGy_r, RdPu, RdPu_r, RdYlBu, RdYlBu_r, RdYlGn, RdYlGn_r, Reds, Reds_r, Set1, Set1_r, Set2, Set2_r, Set3, Set3_r, Spectral, Spectral_r, Wistia, Wistia_r, YlGn, YlGnBu, YlGnBu_r, YlGn_r, YlOrBr, YlOrBr_r, YlOrRd, YlOrRd_r, afmhot, afmhot_r, autumn, autumn_r, binary, binary_r, bone, bone_r, brg, brg_r, bwr, bwr_r, cividis, cividis_r, cool, cool_r, coolwarm, coolwarm_r, copper, copper_r, cubehelix, cubehelix_r, flag, flag_r, gist_earth, gist_earth_r, gist_gray, gist_gray_r, gist_heat, gist_heat_r, gist_ncar, gist_ncar_r, gist_rainbow, gist_rainbow_r, gist_stern, gist_stern_r, gist_yarg, gist_yarg_r, gnuplot, gnuplot2, gnuplot2_r, gnuplot_r, gray, gray_r, hot, hot_r, hsv, hsv_r, inferno, inferno_r, jet, jet_r, magma, magma_r, nipy_spectral, nipy_spectral_r, ocean, ocean_r, pink, pink_r, plasma, plasma_r, prism, prism_r, rainbow, rainbow_r, seismic, seismic_r, spring, spring_r, summer, summer_r, tab10, tab10_r, tab20, tab20_r, tab20b, tab20b_r, tab20c, tab20c_r, terrain, terrain_r, twilight, twilight_r, twilight_shifted, twilight_shifted_r, viridis, viridis_r, winter, winter_r&quot;&quot;&quot;

cmap_name_list = cmap.split(sep = &quot;, &quot;)
</pre></div>


<p><strong>Output &gt;&gt;&gt;</strong></p>


<div class="wp-block-syntaxhighlighter-code "><pre class="brush: python; title: ; notranslate">
&#x5B;'Accent',
 'Accent_r',
 'Blues',
 .
 .
 .
 'viridis_r',
 'winter',
 'winter_r']
</pre></div>


<p>Using cmap name create a unique address to store or save generated image in a folder.</p>


<div class="wp-block-syntaxhighlighter-code "><pre class="brush: python; title: ; notranslate">
save_image_addr_name = &#x5B;]
for i in range(len(cmap_name_list)):
    cmap_str = cmap_name_list&#x5B;i]
    save_image_addr_name.append(&quot;D:\\\cmap_image\\\_&quot;+&quot;girl_&quot; + cmap_name_list&#x5B;i] + &quot;.png&quot;)
    print(save_image_addr_name&#x5B;i])
</pre></div>


<p><strong>Output &gt;&gt;&gt;</strong></p>


<div class="wp-block-syntaxhighlighter-code "><pre class="brush: python; title: ; notranslate">
D:\\cmap_image\\_girl_Accent.png
D:\\cmap_image\\_girl_Accent_r.png
D:\\cmap_image\\_girl_Blues.png
D:\\cmap_image\\_girl_Blues_r.png
D:\\cmap_image\\_girl_BrBG.png
D:\\cmap_image\\_girl_BrBG_r.png
D:\\cmap_image\\_girl_BuGn.png
D:\\cmap_image\\_girl_BuGn_r.png
D:\\cmap_image\\_girl_BuPu.png
.
.
.
.
.
D:\\cmap_image\\_girl_twilight.png
D:\\cmap_image\\_girl_twilight_r.png
D:\\cmap_image\\_girl_twilight_shifted.png
D:\\cmap_image\\_girl_twilight_shifted_r.png
D:\\cmap_image\\_girl_viridis.png
D:\\cmap_image\\_girl_viridis_r.png
D:\\cmap_image\\_girl_winter.png
D:\\cmap_image\\_girl_winter_r.png
</pre></div>


<p>Using <strong>cmap_name_list </strong>and <strong>save_image_addr_name</strong> generate cmap image and save it define location with unique address. </p>


<div class="wp-block-syntaxhighlighter-code "><pre class="brush: python; title: ; notranslate">
for i in range(len(cmap_name_list)): 
    cmap_name = cmap_name_list&#x5B;i]
    plt.figure(figsize=(16,9))
    plt.axis(&quot;off&quot;)
    
    print(cmap_name)

    plt.imshow(single_channel2_img, cmap=cmap_name)
    #plt.colorbar()
    #save_image_name1 = &quot;D:\\cmap_image\\&quot;+&quot;girl&quot; + cmap_list&#x5B;i]
    print(save_image_addr_name&#x5B;i])
    plt.savefig(save_image_addr_name&#x5B;i], orientation='portrate', facecolor= &quot;k&quot;)
    plt.show()
</pre></div>


<p><strong>Output &gt;&gt;&gt;</strong></p>



<figure class="wp-block-image is-resized"><img loading="lazy" decoding="async" src="https://i2.wp.com/indianaiproduction.com/wp-content/uploads/2019/07/matplotlib-imshow-model-with-all-cmap-min.png?fit=640%2C469&amp;ssl=1" alt="matplotlib imshow - model with all cmap values" class="wp-image-894" width="640" height="469" srcset="https://i0.wp.com/indianaiproduction.com/wp-content/uploads/2019/07/matplotlib-imshow-model-with-all-cmap-min.png?w=1150&amp;ssl=1 1150w, https://i0.wp.com/indianaiproduction.com/wp-content/uploads/2019/07/matplotlib-imshow-model-with-all-cmap-min.png?resize=300%2C220&amp;ssl=1 300w, https://i0.wp.com/indianaiproduction.com/wp-content/uploads/2019/07/matplotlib-imshow-model-with-all-cmap-min.png?resize=768%2C562&amp;ssl=1 768w, https://i0.wp.com/indianaiproduction.com/wp-content/uploads/2019/07/matplotlib-imshow-model-with-all-cmap-min.png?resize=1024%2C750&amp;ssl=1 1024w" sizes="(max-width: 640px) 100vw, 640px" /></figure>



<h2 class="wp-block-heading">Conclusion</h2>



<p>In the&nbsp;<strong>matplotlib imshow </strong>blog, we learn how to read, show image and colorbar with a real-time example using the <strong>mpimg.imread, plt.imshow()</strong> and <strong>plt.colorbar() </strong>function. Along with that used different method and different parameter. We suggest you make your hand dirty with each and every parameter of the above methods. This is the best coding practice. After completion of the <a rel="noreferrer noopener" href="https://indianaiproduction.com/python-matplotlib-tutorial/" target="_blank">matplotlib tutorial</a>&nbsp;jump on Seaborn.</p>



<p> Download Jupyter file of matplotlib imshow source code </p>


<div class="su-button-center"><a href="https://drive.google.com/file/d/1QBHn8jIMz4oj-hmnZfRwDGqEDY0vEnZv/view?usp=sharing" class="su-button su-button-style-3d" style="color:#FFFFFF;background-color:#38bb04;border-color:#2d9604;border-radius:24px" target="_self"><span style="color:#FFFFFF;padding:5px 14px;font-size:12px;line-height:18px;border-color:#74d050;border-radius:24px;text-shadow:none"><i class="sui sui-cloud-download" style="font-size:12px;color:#FFFFFF"></i> Matplotlib imshow source code</span></a></div>



<p>

 Visit the official site of&nbsp;<a href="https://www.matplotlib.org/">matplotlib.org</a></p>
<p>The post <a rel="nofollow" href="https://indianaiproduction.com/matplotlib-imshow/">Matplotlib imshow &#8211; Read &#038; Show image using imread() &#038; plt.imshow()</a> appeared first on <a rel="nofollow" href="https://indianaiproduction.com">Indian AI Production</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://indianaiproduction.com/matplotlib-imshow/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
		<post-id xmlns="com-wordpress:feed-additions:1">873</post-id>	</item>
		<item>
		<title>Matplotlib savefig  &#8211; Matplotlib Save Figure &#124; Python matplotlib Tutorial</title>
		<link>https://indianaiproduction.com/matplotlib-savefig/</link>
					<comments>https://indianaiproduction.com/matplotlib-savefig/#respond</comments>
		
		<dc:creator><![CDATA[Indian AI Production]]></dc:creator>
		<pubDate>Mon, 15 Jul 2019 14:00:16 +0000</pubDate>
				<category><![CDATA[Python Matplotlib Tutorial]]></category>
		<category><![CDATA[matplotlib save figure]]></category>
		<category><![CDATA[matplotlib savefig]]></category>
		<category><![CDATA[plt.savefig()]]></category>
		<category><![CDATA[savefig]]></category>
		<guid isPermaLink="false">https://indianaiproduction.com/?p=770</guid>

					<description><![CDATA[<p>Matplotlib Save Figure After creating a plot or chart using the python matplotlib library and need to save and use it further. Then the matplotlib savefig function will help you. In this blog, we are explaining, how to save a figure using matplotlib? Import Library Matplotlib SaveFig (save figure) Different ways Syntax: plt.savefig(     &#8230;</p>
<p class="read-more"> <a class="" href="https://indianaiproduction.com/matplotlib-savefig/"> <span class="screen-reader-text">Matplotlib savefig  &#8211; Matplotlib Save Figure &#124; Python matplotlib Tutorial</span> Read More &#187;</a></p>
<p>The post <a rel="nofollow" href="https://indianaiproduction.com/matplotlib-savefig/">Matplotlib savefig  &#8211; Matplotlib Save Figure | Python matplotlib Tutorial</a> appeared first on <a rel="nofollow" href="https://indianaiproduction.com">Indian AI Production</a>.</p>
]]></description>
										<content:encoded><![CDATA[
<h2>Matplotlib Save Figure</h2>
<p>After creating a plot or chart using the <a href="https://indianaiproduction.com/python-matplotlib-tutorial/" target="_blank" rel="noopener noreferrer">python matplotlib</a> library and need to save and use it further. Then the <strong>matplotlib savefig</strong> function will help you. In this blog, we are explaining, how to save a figure using matplotlib?</p>



<h4>Import Library</h4>


<div class="wp-block-syntaxhighlighter-code "><pre class="brush: python; title: ; notranslate">
import matplotlib.pyplot as plt # for data visualization 
</pre></div>


<h3>Matplotlib SaveFig (save figure) Different ways</h3>
<p><span style="color: #008000;"><strong><span style="color: #ff0000;">Syntax:</span> <span style="color: #800000;">plt.savefig(</span></strong></span></p>
<p><span style="color: #008000;"><strong>                                   &#8220;File path with name or name&#8221;, </strong></span><br /><span style="color: #008000;"><strong>                                   dpi=None, </strong></span><br /><span style="color: #008000;"><strong>                                   quality = 99,</strong></span><br /><span style="color: #008000;"><strong>                                   facecolor=&#8217;w&#8217;, </strong></span><br /><span style="color: #008000;"><strong>                                   edgecolor=&#8217;w&#8217;,</strong></span><br /><span style="color: #008000;"><strong>                                   orientation=&#8217;portrait&#8217;, </strong></span><br /><span style="color: #008000;"><strong>                                   papertype=None, </strong></span><br /><span style="color: #008000;"><strong>                                   format=None,</strong></span><br /><span style="color: #008000;"><strong>                                   transparent=False, </strong></span><br /><span style="color: #008000;"><strong>                                   bbox_inches=None, </strong></span><br /><span style="color: #008000;"><strong>                                   pad_inches=0.1,</strong></span><br /><span style="color: #008000;"><strong>                                   frameon=None, </strong></span><br /><span style="color: #008000;"><strong>                                   metadata=None,</strong></span></p>
<p><span style="color: #008000;"><strong>                                <span style="color: #800000;">   )</span></strong></span></p>
<p><span style="font-size: 14pt;"><strong>Recommended Value Type for Parameters </strong></span></p>
<p>fname : str or file-like object<br />dpi : [ *None* | scalar &gt; 0 | &#8216;figure&#8217; ]quality : [ *None* | 1 &lt;= scalar &lt;= 100 ] <br />facecolor : color spec or None, optional <br />edgecolor : color spec or None, optional <br />orientation : {&#8216;landscape&#8217;, &#8216;portrait&#8217;} <br />papertype : str <br />&#8212; &#8216;letter&#8217;, &#8216;legal&#8217;, &#8216;executive&#8217;, &#8216;ledger&#8217;, &#8216;a0&#8217; through<br />&#8216;a10&#8217;, &#8216;b0&#8217; through &#8216;b10&#8217;<br />format : str &#8212;png, pdf, ps, eps and svg<br />transparent : bool<br />frameon : bool <br />bbox_inches : str or `~matplotlib.transforms.Bbox`, optional <br />pad_inches : scalar, optional <br />bbox_extra_artists : list of `~matplotlib.artist.Artist`, optional<br />metadata : dict, optional</p>



<p>Here, we are creating a simple <a href="https://indianaiproduction.com/matplotlib-pie-chart/" target="_blank" rel="noopener noreferrer">pie chart</a> and save it using <strong>plt.savefig()</strong> function. The file saves at program file location by default with &#8220;.png&#8221; format. You can change the file path. </p>


<div class="wp-block-syntaxhighlighter-code "><pre class="brush: plain; title: ; notranslate">
plt.pie(&#x5B;40,30,20]) # plot pie chart
plt.savefig(&quot;pie_char&quot;) # save above pie chart with name pie_chart
plt.show()
</pre></div>


<p><strong>Output &gt;&gt;&gt;</strong></p>
<p><img loading="lazy" decoding="async" class="aligncenter wp-image-774 size-full" src="https://i0.wp.com/indianaiproduction.com/wp-content/uploads/2019/07/Pie-Chart.png?resize=314%2C314&#038;ssl=1" alt="Pie Chart" width="314" height="314" srcset="https://i0.wp.com/indianaiproduction.com/wp-content/uploads/2019/07/Pie-Chart.png?w=314&amp;ssl=1 314w, https://i0.wp.com/indianaiproduction.com/wp-content/uploads/2019/07/Pie-Chart.png?resize=150%2C150&amp;ssl=1 150w, https://i0.wp.com/indianaiproduction.com/wp-content/uploads/2019/07/Pie-Chart.png?resize=300%2C300&amp;ssl=1 300w" sizes="(max-width: 314px) 100vw, 314px" data-recalc-dims="1" /></p>
<p><strong>Saved Image &gt;&gt;&gt;</strong></p>
<figure id="attachment_775" aria-describedby="caption-attachment-775" style="width: 579px" class="wp-caption aligncenter"><img loading="lazy" decoding="async" class="size-full wp-image-775" src="https://i0.wp.com/indianaiproduction.com/wp-content/uploads/2019/07/Matplotlib-Savefig.png?resize=579%2C390&#038;ssl=1" alt="Matplotlib Savefig" width="579" height="390" srcset="https://i0.wp.com/indianaiproduction.com/wp-content/uploads/2019/07/Matplotlib-Savefig.png?w=579&amp;ssl=1 579w, https://i0.wp.com/indianaiproduction.com/wp-content/uploads/2019/07/Matplotlib-Savefig.png?resize=300%2C202&amp;ssl=1 300w" sizes="(max-width: 579px) 100vw, 579px" data-recalc-dims="1" /><figcaption id="caption-attachment-775" class="wp-caption-text">pie_chart.png</figcaption></figure>



<h4>Save Matplolib Figure using some parameters</h4>


<div class="wp-block-syntaxhighlighter-code "><pre class="brush: python; title: ; notranslate">
plt.pie(&#x5B;40,30,20])
plt.savefig(&quot;pie_char2&quot;, # file name
            dpi = 100,  # dot per inch for resolution increase value for more resolution
            quality = 99, # &quot;1 &lt;= value &lt;= 100&quot; 100 for best qulity
            facecolor = &quot;g&quot; # image background color
           )
plt.show()
</pre></div>


<p><strong>Output &gt;&gt;&gt;</strong></p>
<p><img loading="lazy" decoding="async" class="aligncenter size-full wp-image-774" src="https://i0.wp.com/indianaiproduction.com/wp-content/uploads/2019/07/Pie-Chart.png?resize=314%2C314&#038;ssl=1" alt="Pie Chart" width="314" height="314" srcset="https://i0.wp.com/indianaiproduction.com/wp-content/uploads/2019/07/Pie-Chart.png?w=314&amp;ssl=1 314w, https://i0.wp.com/indianaiproduction.com/wp-content/uploads/2019/07/Pie-Chart.png?resize=150%2C150&amp;ssl=1 150w, https://i0.wp.com/indianaiproduction.com/wp-content/uploads/2019/07/Pie-Chart.png?resize=300%2C300&amp;ssl=1 300w" sizes="(max-width: 314px) 100vw, 314px" data-recalc-dims="1" /></p>
<p><strong>Saved Image &gt;&gt;&gt;</strong></p>
<figure id="attachment_776" aria-describedby="caption-attachment-776" style="width: 579px" class="wp-caption aligncenter"><img loading="lazy" decoding="async" class="size-full wp-image-776" src="https://i0.wp.com/indianaiproduction.com/wp-content/uploads/2019/07/Matplotlib-Savefig-with-parameters.png?resize=579%2C390&#038;ssl=1" alt="Matplotlib Savefig with parameters" width="579" height="390" srcset="https://i0.wp.com/indianaiproduction.com/wp-content/uploads/2019/07/Matplotlib-Savefig-with-parameters.png?w=579&amp;ssl=1 579w, https://i0.wp.com/indianaiproduction.com/wp-content/uploads/2019/07/Matplotlib-Savefig-with-parameters.png?resize=300%2C202&amp;ssl=1 300w" sizes="(max-width: 579px) 100vw, 579px" data-recalc-dims="1" /><figcaption id="caption-attachment-776" class="wp-caption-text">pie_chart2.png</figcaption></figure>



<h3>Example:</h3>
<p>In bellow example, create plots and charts and show using <a href="https://indianaiproduction.com/matplotlib-subplot/" target="_blank" rel="noopener noreferrer">subplot function</a>. Then line no. &#8220;<span style="color: #00ff00;">105</span>&#8221; <span style="background-color: #999999; font-family: 'courier new', courier, monospace; color: #ffffff;">(plt.savefig(&#8220;D:\\subplot_figure.png&#8221;)) </span>save this subplot at user define location.</p>


<div class="wp-block-syntaxhighlighter-code "><pre class="brush: python; title: ; notranslate">
plt.figure(figsize=(23,27))

##----------------------------------------start 
#plt.subplot(3,2,1)
plt.subplot(321)
#********************************************Line Plot
days = &#x5B;1,2,3,4,5,6,7,8,9,10,11,12,13,14,15]
delhi_tem = &#x5B;36.6, 37, 37.7,39,40.1,43,43.4,45,45.6,40.1,44,45,46.8,47,47.8]
mumbai_tem = &#x5B;39,39.4,40,40.7,41,42.5,43.5,44,44.9,44,45,45.1,46,47,46]

plt.plot(days, delhi_tem, &quot;mo--&quot;, linewidth = 3,
        markersize = 10, label = &quot;Delhi tem&quot;)

plt.plot(days, mumbai_tem, &quot;yo:&quot;, linewidth = 3,
        markersize = 10, label = &quot;Mumbai tem}&quot;)

plt.title(&quot;Delhi  &amp; Mumbai Temperature Line Plot&quot;, fontsize=15)
plt.xlabel(&quot;days&quot;,fontsize=13)
plt.ylabel(&quot;temperature&quot;,fontsize=13)
plt.legend(loc = 4)
plt.grid(color='w', linestyle='-', linewidth=2)

#---------------------------------------------------------------end

plt.subplot(3,2,2) ##-------------------------------------------------start
#****************************************************************histograms
ml_students_age = np.random.randint(18,45, (100))
py_students_age = np.random.randint(15,40, (100))
bins = &#x5B;15,20,25,30,35,40,45]

plt.hist(&#x5B;ml_students_age, py_students_age], bins, rwidth=0.8, histtype = &quot;bar&quot;,
         orientation='vertical', color = &#x5B;&quot;m&quot;, &quot;y&quot;], label = &#x5B;&quot;ML Student&quot;, &quot;Py Student&quot;])

plt.title(&quot;ML &amp; Py Students age histograms&quot;)
plt.xlabel(&quot;Students age cotegory&quot;)
plt.ylabel(&quot;No. Students age&quot;)
plt.legend()
#----------------------------------------------------------------------end

plt.subplot(3,2,3) ##--------------------------------------------start
#************************************************************Bar Chart
classes = &#x5B;&quot;Python&quot;, &quot;R&quot;, &quot;AI&quot;, &quot;ML&quot;, &quot;DS&quot;]
class1_students = &#x5B;30, 10, 20, 25, 10] # out of 100 student in each class
class2_students = &#x5B;40, 5, 20, 20, 10]
class3_students = &#x5B;35, 5, 30, 15, 15]
classes_index = np.arange(len(classes))

width = 0.2

plt.barh(classes_index, class1_students, width , color = &quot;b&quot;,
        label =&quot; Class 1 Students&quot;) #visible=False

plt.barh(classes_index + width, class2_students, width , color = &quot;g&quot;,
        label =&quot; Class 2 Students&quot;) 

plt.barh(classes_index + width + width, class3_students, width , color = &quot;y&quot;,
        label =&quot; Class 3 Students&quot;) 

plt.yticks(classes_index + width, classes, rotation = 20)
plt.title(&quot;Bar Chart of IAIP Class Bar Chart&quot;, fontsize = 18)
plt.ylabel(&quot;Classes&quot;,fontsize = 15)
plt.xlabel(&quot;No. of Students&quot;, fontsize = 15)
plt.legend()
#--------------------------------------------------------------------end

plt.subplot(3,2,4) ##------------------------------------------------start
#**************************************************************Scatter Plot
df_google_play_store_apps = pd.read_csv(&quot;D:\\Private\Indina AI Production\Kaggel Dataset\google-play-store-apps\googleplaystore.csv&quot;, nrows = 1000)
x = df_google_play_store_apps&#x5B;&quot;Rating&quot;]
y = df_google_play_store_apps&#x5B;&quot;Reviews&quot;]
plt.scatter(x,y, c = &quot;r&quot;, marker = &quot;*&quot;, s = 100, alpha=0.5, linewidths=10,
           edgecolors=&quot;g&quot; )#verts=&quot;&lt;&quot;

plt.scatter(x,df_google_play_store_apps&#x5B;&quot;Installs&quot;], c = &quot;y&quot;, marker = &quot;o&quot;, s = 100, alpha=0.5, linewidths=10,
           edgecolors=&quot;c&quot; )
plt.title(&quot;Google Play Store Apps Scatter plot&quot;)
plt.xlabel(&quot;Rating&quot;)
plt.ylabel(&quot;Reviews &amp; Installs&quot;)
#----------------------------------------------------------------------end


plt.subplot(3,2,5) ##-----------------------------------------start
#*************************************************************Pie plot
classes = &#x5B;&quot;Python&quot;, 'R', 'Machine Learning', 'Artificial Intelligence', 
           'Data Sciece']
class1_students = &#x5B;45, 15, 35, 25, 30]
explode = &#x5B;0.03,0,0.1,0,0]
colors = &#x5B;&quot;c&quot;, 'b','r','y','g']
textprops = {&quot;fontsize&quot;:15}

plt.pie(class1_students, 
        labels = classes, 
        explode = explode, 
        colors =colors, 
        autopct = &quot;%0.2f%%&quot;, 
        shadow = True, 
        radius = 1.4,
       startangle = 270, 
        textprops =textprops)
#------------------------------------------------------end


plt.subplot(3,2,6, projection='polar', facecolor='k' ,frameon=True)

plt.savefig(&quot;D:\\subplot_figure.png&quot;) # save subplots at drive &quot;D&quot; of name subplot_figure
plt.show()
</pre></div>


<p><strong>Output &gt;&gt;&gt;</strong></p>
<p><img loading="lazy" decoding="async" class="aligncenter size-full wp-image-777" src="https://i0.wp.com/indianaiproduction.com/wp-content/uploads/2019/07/Subplots.png?resize=1200%2C1290&#038;ssl=1" alt="Matplotlib Subplots" width="1200" height="1290" srcset="https://i0.wp.com/indianaiproduction.com/wp-content/uploads/2019/07/Subplots.png?w=1335&amp;ssl=1 1335w, https://i0.wp.com/indianaiproduction.com/wp-content/uploads/2019/07/Subplots.png?resize=279%2C300&amp;ssl=1 279w, https://i0.wp.com/indianaiproduction.com/wp-content/uploads/2019/07/Subplots.png?resize=768%2C826&amp;ssl=1 768w, https://i0.wp.com/indianaiproduction.com/wp-content/uploads/2019/07/Subplots.png?resize=953%2C1024&amp;ssl=1 953w" sizes="(max-width: 1200px) 100vw, 1200px" data-recalc-dims="1" /></p>



<p><strong>Saved Image &gt;&gt;&gt;</strong></p>
<figure id="attachment_779" aria-describedby="caption-attachment-779" style="width: 579px" class="wp-caption aligncenter"><img loading="lazy" decoding="async" class="size-full wp-image-779" src="https://i0.wp.com/indianaiproduction.com/wp-content/uploads/2019/07/Matplotlib-Savefig-subplots.png?resize=579%2C678&#038;ssl=1" alt="Matplotlib Savefig - subplots" width="579" height="678" srcset="https://i0.wp.com/indianaiproduction.com/wp-content/uploads/2019/07/Matplotlib-Savefig-subplots.png?w=579&amp;ssl=1 579w, https://i0.wp.com/indianaiproduction.com/wp-content/uploads/2019/07/Matplotlib-Savefig-subplots.png?resize=256%2C300&amp;ssl=1 256w" sizes="(max-width: 579px) 100vw, 579px" data-recalc-dims="1" /><figcaption id="caption-attachment-779" class="wp-caption-text">subplot_figure.png</figcaption></figure>



<h2>CONCLUSION</h2>
<p>In the <strong>matplotlib save figure </strong>blog, we learn how to save figure with a real-time example using the <strong>plt.savefig()</strong> function. Along with that used different method and different parameter. We suggest you make your hand dirty with each and every parameter of the above methods. This is the best coding practice. After completion of the <a href="https://indianaiproduction.com/python-matplotlib-tutorial/" target="_blank" rel="noreferrer noopener">matplotlib tutorial</a> jump on Seaborn.</p>



<p>Download Jupyter file of matplotlib savefig source code</p>


<div class="su-button-center"><a href="https://drive.google.com/file/d/1vbJGg4cY7Tyimg_3TZhwoXKaresnNKHA/view?usp=sharing" class="su-button su-button-style-3d" style="color:#FFFFFF;background-color:#38bb04;border-color:#2d9604;border-radius:24px" target="_self"><span style="color:#FFFFFF;padding:5px 14px;font-size:12px;line-height:18px;border-color:#74d050;border-radius:24px;text-shadow:none"><i class="sui sui-cloud-download" style="font-size:12px;color:#FFFFFF"></i> Matplotlib save figure source code</span></a></div>



<p>

Visit the official site of&nbsp;<a href="https://www.matplotlib.org/">matplotlib.org</a></p>
<p>The post <a rel="nofollow" href="https://indianaiproduction.com/matplotlib-savefig/">Matplotlib savefig  &#8211; Matplotlib Save Figure | Python matplotlib Tutorial</a> appeared first on <a rel="nofollow" href="https://indianaiproduction.com">Indian AI Production</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://indianaiproduction.com/matplotlib-savefig/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
		<post-id xmlns="com-wordpress:feed-additions:1">770</post-id>	</item>
		<item>
		<title>Matplotlib Subplot &#8211; plt.subplot() &#124; Python Matplolib Tutorial</title>
		<link>https://indianaiproduction.com/matplotlib-subplot/</link>
					<comments>https://indianaiproduction.com/matplotlib-subplot/#respond</comments>
		
		<dc:creator><![CDATA[Indian AI Production]]></dc:creator>
		<pubDate>Sun, 14 Jul 2019 14:34:05 +0000</pubDate>
				<category><![CDATA[Python Matplotlib Tutorial]]></category>
		<category><![CDATA[matplotlib subplot]]></category>
		<category><![CDATA[matplotlib subplots]]></category>
		<category><![CDATA[Matplotlib Tutorial]]></category>
		<category><![CDATA[plt.subplot()]]></category>
		<category><![CDATA[subplot]]></category>
		<guid isPermaLink="false">https://indianaiproduction.com/?p=765</guid>

					<description><![CDATA[<p>Matplotlib Subplot This blog under construction but you can download sourse code In matplolib subplot blog, discusing on how to plot subplots using plt.subplot() function. Imort Libraries Create matplotlib subplotls Creating 4 subplot with 2 rows and 2 columns. Output &#62;&#62;&#62; Download Jupyter file of matplotlib Subplot source code</p>
<p>The post <a rel="nofollow" href="https://indianaiproduction.com/matplotlib-subplot/">Matplotlib Subplot &#8211; plt.subplot() | Python Matplolib Tutorial</a> appeared first on <a rel="nofollow" href="https://indianaiproduction.com">Indian AI Production</a>.</p>
]]></description>
										<content:encoded><![CDATA[
<h2 class="wp-block-heading">Matplotlib Subplot</h2>



<p>

This blog under construction but you can download sourse code

</p>



<p>In <strong>matplolib subplot</strong> blog, discusing on how to plot subplots using <strong>plt.subplot()</strong> function.</p>



<h4>Imort Libraries</h4>


<div class="wp-block-syntaxhighlighter-code "><pre class="brush: python; title: ; notranslate">
import matplotlib.pyplot as plt
import numpy as np
import pandas as pd
import random
from matplotlib import style
</pre></div>


<h4>Create matplotlib subplotls</h4>



<p>Creating 4 subplot with 2 rows and 2 columns.</p>


<div class="wp-block-syntaxhighlighter-code "><pre class="brush: python; title: ; notranslate">
# Create 4 subplot (2- rows and 2 - columns)
plt.subplot(2,2,1)

plt.subplot(2,2,2)

plt.subplot(2,2,3)

plt.subplot(2,2,4)

plt.show()
</pre></div>


<p><strong>Output &gt;&gt;&gt;</strong></p>



<p>Download Jupyter file of matplotlib Subplot source code</p>


<div class="su-button-center"><a href="https://drive.google.com/file/d/1xDCt3hXsTB33KmOzlWPFyqh8rCoKki08/view?usp=sharing" class="su-button su-button-style-3d" style="color:#FFFFFF;background-color:#38bb04;border-color:#2d9604;border-radius:24px" target="_self"><span style="color:#FFFFFF;padding:5px 14px;font-size:12px;line-height:18px;border-color:#74d050;border-radius:24px;text-shadow:none"><i class="sui sui-cloud-download" style="font-size:12px;color:#FFFFFF"></i> Matplotlib subplor source code</span></a></div>
<p>The post <a rel="nofollow" href="https://indianaiproduction.com/matplotlib-subplot/">Matplotlib Subplot &#8211; plt.subplot() | Python Matplolib Tutorial</a> appeared first on <a rel="nofollow" href="https://indianaiproduction.com">Indian AI Production</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://indianaiproduction.com/matplotlib-subplot/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
		<post-id xmlns="com-wordpress:feed-additions:1">765</post-id>	</item>
		<item>
		<title>Matplotlib Scatter Plot &#8211; plt.scatter() &#124; Python Matplotlib Tutorial</title>
		<link>https://indianaiproduction.com/matplotlib-scatter-plot/</link>
					<comments>https://indianaiproduction.com/matplotlib-scatter-plot/#comments</comments>
		
		<dc:creator><![CDATA[Indian AI Production]]></dc:creator>
		<pubDate>Sun, 14 Jul 2019 06:57:42 +0000</pubDate>
				<category><![CDATA[Python Matplotlib Tutorial]]></category>
		<category><![CDATA[matplotlib scatter]]></category>
		<category><![CDATA[matplotlib scatter plot]]></category>
		<category><![CDATA[plt.scatter()]]></category>
		<category><![CDATA[scatter plot]]></category>
		<guid isPermaLink="false">https://indianaiproduction.com/?p=729</guid>

					<description><![CDATA[<p>Matplotlib Scatter Plot In the matplotlib scatter plot blog will discuss, how to draw a scatter plot using python matplotlib plt.scatter() function. The plt.scatter() function help to plot two-variable datasets in point or a user-defined format. Here, we will be plotting google play store apps scatter plot. Import Libraries Import Dataset The data frame contains &#8230;</p>
<p class="read-more"> <a class="" href="https://indianaiproduction.com/matplotlib-scatter-plot/"> <span class="screen-reader-text">Matplotlib Scatter Plot &#8211; plt.scatter() &#124; Python Matplotlib Tutorial</span> Read More &#187;</a></p>
<p>The post <a rel="nofollow" href="https://indianaiproduction.com/matplotlib-scatter-plot/">Matplotlib Scatter Plot &#8211; plt.scatter() | Python Matplotlib Tutorial</a> appeared first on <a rel="nofollow" href="https://indianaiproduction.com">Indian AI Production</a>.</p>
]]></description>
										<content:encoded><![CDATA[
<h2>Matplotlib Scatter Plot</h2>



<p>In the <strong>matplotlib scatter plot</strong> blog will discuss, how to draw a <strong>scatter plot</strong> using python matplotlib <strong>plt.scatter()</strong> function. The plt.scatter() function help to plot two-variable datasets in point or a user-defined format. Here, we will be plotting google play store apps scatter plot.</p>



<h4>Import Libraries</h4>


<div class="wp-block-syntaxhighlighter-code "><pre class="brush: python; title: ; notranslate">
import matplotlib.pyplot as plt # For visualization
import pandas as pd # for data cleaing &amp; analysis
</pre></div>


<h4>Import Dataset</h4>


<div class="wp-block-syntaxhighlighter-code "><pre class="brush: python; title: ; notranslate">
# Dataset taken from kaggel.com
df_google_play_store_apps = pd.read_csv(&quot;D:\\Private\Indina AI Production\Kaggel Dataset\google-play-store-apps\googleplaystore.csv&quot;)
df_google_play_store_apps.shape # Get shape of dataset in rows and colms
</pre></div>

<div class="wp-block-syntaxhighlighter-code "><pre class="brush: plain; title: ; notranslate">
Output &gt;&gt;&gt;
          (10841, 13) # (rows, colomns) of data frame
</pre></div>

<div class="su-button-center"><a href="https://www.kaggle.com/lava18/google-play-store-apps/downloads/google-play-store-apps.zip/6" class="su-button su-button-style-3d" style="color:#FFFFFF;background-color:#38bb04;border-color:#2d9604;border-radius:24px" target="_blank" rel="noopener noreferrer"><span style="color:#FFFFFF;padding:5px 14px;font-size:12px;line-height:18px;border-color:#74d050;border-radius:24px;text-shadow:none"><i class="sui sui-cloud-download" style="font-size:12px;color:#FFFFFF"></i> Google Play Store Apps Dataset Download</span></a></div>



<p>The data frame contains 10841 rows and we wants only 1000 rows , so for use <strong>nrow</strong> parameter of <strong>pd.DataFrame().&nbsp;</strong>You can work on hole dtaset its your choice.</p>


<div class="wp-block-syntaxhighlighter-code "><pre class="brush: python; title: ; notranslate">
df_google_play_store_apps = pd.read_csv(&quot;D:\\Private\Indina AI Production\Kaggel Dataset\google-play-store-apps\googleplaystore.csv&quot;, 
                                        nrows = 1000)
df_google_play_store_apps.shape ## Get shape of dataset in rows and colms
</pre></div>

<div class="wp-block-syntaxhighlighter-code "><pre class="brush: plain; title: ; notranslate">
Output &gt;&gt;&gt;
          (1000, 13) # (rows, colomns) of data frame
</pre></div>


<h4>View Data Frame Sample&nbsp;</h4>


<div class="wp-block-syntaxhighlighter-code "><pre class="brush: python; title: ; notranslate">
df_google_play_store_apps
</pre></div>


<p><strong data-rich-text-format-boundary="true">Output &gt;&gt;&gt;</strong></p>
<p><img loading="lazy" decoding="async" class="aligncenter size-full wp-image-736" src="https://i0.wp.com/indianaiproduction.com/wp-content/uploads/2019/07/Google-Play-Store-Apps-Data-Frame-1.png?resize=1200%2C682&#038;ssl=1" alt="Google Play Store Apps Data Frame " width="1200" height="682" srcset="https://i0.wp.com/indianaiproduction.com/wp-content/uploads/2019/07/Google-Play-Store-Apps-Data-Frame-1.png?w=1351&amp;ssl=1 1351w, https://i0.wp.com/indianaiproduction.com/wp-content/uploads/2019/07/Google-Play-Store-Apps-Data-Frame-1.png?resize=300%2C171&amp;ssl=1 300w, https://i0.wp.com/indianaiproduction.com/wp-content/uploads/2019/07/Google-Play-Store-Apps-Data-Frame-1.png?resize=768%2C437&amp;ssl=1 768w, https://i0.wp.com/indianaiproduction.com/wp-content/uploads/2019/07/Google-Play-Store-Apps-Data-Frame-1.png?resize=1024%2C582&amp;ssl=1 1024w" sizes="(max-width: 1200px) 100vw, 1200px" data-recalc-dims="1" /></p>



<p>The data frame contain numeric and string typle value and for scatter plot need numeric value. So, we are ploting scatter plot of Google Play Store Apps Data Frame 1as x and <strong>Reviews</strong> as y coloms data.</p>


<div class="wp-block-syntaxhighlighter-code "><pre class="brush: python; title: ; notranslate">
x = df_google_play_store_apps&#x5B;&quot;Rating&quot;]
y = df_google_play_store_apps&#x5B;&quot;Reviews&quot;]
</pre></div>


<h3>Plot Scatter plot using matplotlib</h3>
<p><span style="color: #ff0000;"><strong>Syntax : <span style="color: #800000;">plt.scatter(</span></strong></span></p>
<p><span style="color: #008000;"><strong>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; x,</strong></span><br><span style="color: #008000;"><strong>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; y,</strong></span><br><span style="color: #008000;"><strong>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; s=None,</strong></span><br><span style="color: #008000;"><strong>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; c=None,</strong></span><br><span style="color: #008000;"><strong>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; marker=None,&nbsp;</strong></span><br><span style="color: #008000;"><strong>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; cmap=None,</strong></span><br><span style="color: #008000;"><strong>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; norm=None,</strong></span><br><span style="color: #008000;"><strong>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; vmin=None,</strong></span><br><span style="color: #008000;"><strong>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; vmax=None,</strong></span><br><span style="color: #008000;"><strong>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; alpha=None,</strong></span><br><span style="color: #008000;"><strong>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; linewidths=None,</strong></span><br><span style="color: #008000;"><strong>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; verts=None, ### same work like &#8211; marker</strong></span><br><span style="color: #008000;"><strong>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; edgecolors=None,</strong></span><br><span style="color: #008000;"><strong>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; *,</strong></span><br><span style="color: #008000;"><strong>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; data=None,</strong></span><br><span style="color: #008000;"><strong>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; **kwargs,</strong></span><br><span style="color: #800000;"><strong><span style="color: #008000;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </span>)</strong></span></p>


<div class="wp-block-syntaxhighlighter-code "><pre class="brush: python; title: ; notranslate">
plt.scatter(x,y) # Draw scatter plot with parameter x and y
plt.show()
</pre></div>


<p><strong>Output &gt;&gt;&gt;</strong></p>
<figure id="attachment_737" aria-describedby="caption-attachment-737" style="width: 439px" class="wp-caption aligncenter"><img loading="lazy" decoding="async" class="size-full wp-image-737" src="https://i0.wp.com/indianaiproduction.com/wp-content/uploads/2019/07/Matplotlib-Scatter-Plot-2.png?resize=439%2C315&#038;ssl=1" alt="Matplotlib Scatter Plot " width="439" height="315" srcset="https://i0.wp.com/indianaiproduction.com/wp-content/uploads/2019/07/Matplotlib-Scatter-Plot-2.png?w=439&amp;ssl=1 439w, https://i0.wp.com/indianaiproduction.com/wp-content/uploads/2019/07/Matplotlib-Scatter-Plot-2.png?resize=300%2C215&amp;ssl=1 300w" sizes="(max-width: 439px) 100vw, 439px" data-recalc-dims="1" /><figcaption id="caption-attachment-737" class="wp-caption-text">Fig 1.1 &#8211; Matplotlib Scatter Plot</figcaption></figure>



<p>Show scatter plot with title, xlabel and ylabel.</p>


<div class="wp-block-syntaxhighlighter-code "><pre class="brush: python; title: ; notranslate">
plt.scatter(x,y)
plt.title(&quot;Google Play Store Apps Scatter plot&quot;)
plt.xlabel(&quot;Rating&quot;)
plt.ylabel(&quot;Reviews&quot;)
plt.show()
</pre></div>


<p><strong>Output &gt;&gt;&gt;</strong></p>
<figure id="attachment_738" aria-describedby="caption-attachment-738" style="width: 439px" class="wp-caption aligncenter"><img loading="lazy" decoding="async" class="size-full wp-image-738" src="https://i0.wp.com/indianaiproduction.com/wp-content/uploads/2019/07/plt.scatter-with-function-3.png?resize=439%2C325&#038;ssl=1" alt="Matplotlib Scatter Plot" width="439" height="325" srcset="https://i0.wp.com/indianaiproduction.com/wp-content/uploads/2019/07/plt.scatter-with-function-3.png?w=439&amp;ssl=1 439w, https://i0.wp.com/indianaiproduction.com/wp-content/uploads/2019/07/plt.scatter-with-function-3.png?resize=300%2C222&amp;ssl=1 300w" sizes="(max-width: 439px) 100vw, 439px" data-recalc-dims="1" /><figcaption id="caption-attachment-738" class="wp-caption-text">Fig 1.1 &#8211; Matplotlib Scatter Plot with functions</figcaption></figure>



<p>Ploting Scatter plot with parameters&nbsp;</p>


<div class="wp-block-syntaxhighlighter-code "><pre class="brush: python; title: ; notranslate">
plt.figure(figsize = (16,9)) # figure size ratio 16:9
plt.scatter(x,y, c = &quot;r&quot;, marker = &quot;*&quot;, s = 100, alpha=0.5, linewidths=10,
           edgecolors=&quot;g&quot; )#verts=&quot;&lt;&quot;
plt.title(&quot;Google Play Store Apps Scatter plot&quot;)
plt.xlabel(&quot;Rating&quot;)
plt.ylabel(&quot;Reviews&quot;)
plt.show()
</pre></div>


<p><strong>Output &gt;&gt;&gt;</strong></p>
<figure id="attachment_739" aria-describedby="caption-attachment-739" style="width: 957px" class="wp-caption aligncenter"><img loading="lazy" decoding="async" class="size-full wp-image-739" src="https://i0.wp.com/indianaiproduction.com/wp-content/uploads/2019/07/plt.scatter-with-parameters-4.png?resize=957%2C567&#038;ssl=1" alt="Matplotlib Scatter Plot with parameters" width="957" height="567" srcset="https://i0.wp.com/indianaiproduction.com/wp-content/uploads/2019/07/plt.scatter-with-parameters-4.png?w=957&amp;ssl=1 957w, https://i0.wp.com/indianaiproduction.com/wp-content/uploads/2019/07/plt.scatter-with-parameters-4.png?resize=300%2C178&amp;ssl=1 300w, https://i0.wp.com/indianaiproduction.com/wp-content/uploads/2019/07/plt.scatter-with-parameters-4.png?resize=768%2C455&amp;ssl=1 768w" sizes="(max-width: 957px) 100vw, 957px" data-recalc-dims="1" /><figcaption id="caption-attachment-739" class="wp-caption-text">Fig 1.3 &#8211; Matplotlib Scatter Plot</figcaption></figure>



<h4>Plot Two Scatter Plot in one plot</h4>


<div class="wp-block-syntaxhighlighter-code "><pre class="brush: python; title: ; notranslate">
plt.figure(figsize = (16,9))
plt.scatter(x,y, c = &quot;r&quot;, marker = &quot;*&quot;, s = 100, alpha=0.5, linewidths=10,
           edgecolors=&quot;g&quot; )#verts=&quot;&lt;&quot;

plt.scatter(x,df_google_play_store_apps&#x5B;&quot;Installs&quot;], c = &quot;y&quot;, marker = &quot;o&quot;, s = 100, alpha=0.5, linewidths=10,
           edgecolors=&quot;c&quot; )
plt.title(&quot;Google Play Store Apps Scatter plot&quot;)
plt.xlabel(&quot;Rating&quot;)
plt.ylabel(&quot;Reviews &amp; Installs&quot;)
plt.show()
</pre></div>


<p><strong>Output &gt;&gt;&gt;</strong></p>
<figure id="attachment_740" aria-describedby="caption-attachment-740" style="width: 957px" class="wp-caption aligncenter"><img loading="lazy" decoding="async" class="size-full wp-image-740" src="https://i0.wp.com/indianaiproduction.com/wp-content/uploads/2019/07/Matplotlib-two-scatter-plot-5.png?resize=957%2C526&#038;ssl=1" alt="Matplotlib two scatter plot " width="957" height="526" srcset="https://i0.wp.com/indianaiproduction.com/wp-content/uploads/2019/07/Matplotlib-two-scatter-plot-5.png?w=957&amp;ssl=1 957w, https://i0.wp.com/indianaiproduction.com/wp-content/uploads/2019/07/Matplotlib-two-scatter-plot-5.png?resize=300%2C165&amp;ssl=1 300w, https://i0.wp.com/indianaiproduction.com/wp-content/uploads/2019/07/Matplotlib-two-scatter-plot-5.png?resize=768%2C422&amp;ssl=1 768w" sizes="(max-width: 957px) 100vw, 957px" data-recalc-dims="1" /><figcaption id="caption-attachment-740" class="wp-caption-text">Fig 1.4 &#8211; Matplotlib two scatter plot</figcaption></figure>



<h2>Conclusion</h2>
<p>In the&nbsp;<strong>matplotlib plt.scatter() plot </strong>blog, we learn how to plot one and multiple scatter plot with a real-time example using the <strong>plt.scatter()</strong>&nbsp;method. Along with that used different method and different parameter. We suggest you make your hand dirty with each and every parameter of the above methods. This is the best coding practice. After completion of the&nbsp;<a href="https://indianaiproduction.com/python-matplotlib-tutorial/" target="_blank" rel="noreferrer noopener">matplotlib tutorial</a>&nbsp;jump on Seaborn.</p>



<p>Download Jupyter file of matplotlib scatter plot source code</p>


<div class="su-button-center"><a href="https://drive.google.com/file/d/1Ructll4E8g0QZHp3tMsD9y-bh6-e3DmH/view?usp=sharing" class="su-button su-button-style-3d" style="color:#FFFFFF;background-color:#38bb04;border-color:#2d9604;border-radius:24px" target="_self"><span style="color:#FFFFFF;padding:5px 14px;font-size:12px;line-height:18px;border-color:#74d050;border-radius:24px;text-shadow:none"><i class="sui sui-cloud-download" style="font-size:12px;color:#FFFFFF"></i> Matplotlib Scatter Plot source code</span></a></div>



<p>

Visit the official site of <a href="http://www.matplotlib.org/">matplotlib.org</a></p>
<p>The post <a rel="nofollow" href="https://indianaiproduction.com/matplotlib-scatter-plot/">Matplotlib Scatter Plot &#8211; plt.scatter() | Python Matplotlib Tutorial</a> appeared first on <a rel="nofollow" href="https://indianaiproduction.com">Indian AI Production</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://indianaiproduction.com/matplotlib-scatter-plot/feed/</wfw:commentRss>
			<slash:comments>1</slash:comments>
		
		
		<post-id xmlns="com-wordpress:feed-additions:1">729</post-id>	</item>
		<item>
		<title>Matplotlib Pie Chart &#8211; plt.pie() &#124; Python Matplotlib Tutorial</title>
		<link>https://indianaiproduction.com/matplotlib-pie-chart/</link>
					<comments>https://indianaiproduction.com/matplotlib-pie-chart/#comments</comments>
		
		<dc:creator><![CDATA[Indian AI Production]]></dc:creator>
		<pubDate>Fri, 12 Jul 2019 11:17:36 +0000</pubDate>
				<category><![CDATA[Python Matplotlib Tutorial]]></category>
		<category><![CDATA[Matplotlib Pie chart]]></category>
		<category><![CDATA[pie chart]]></category>
		<category><![CDATA[pie charts]]></category>
		<category><![CDATA[python matplotlib pie chart]]></category>
		<guid isPermaLink="false">https://indianaiproduction.com/?p=712</guid>

					<description><![CDATA[<p>Matplotlib Pie Chart In this blog, we will work on how to draw a matplotlib pie chart? To draw pie char use plt.pie() function. The matplotkib plt.pie() function help to plot pie chart of given numeric data with labels. It also support different parameters which help to show better. Importing Library Plotting Matplotlib Pie Chart &#8230;</p>
<p class="read-more"> <a class="" href="https://indianaiproduction.com/matplotlib-pie-chart/"> <span class="screen-reader-text">Matplotlib Pie Chart &#8211; plt.pie() &#124; Python Matplotlib Tutorial</span> Read More &#187;</a></p>
<p>The post <a rel="nofollow" href="https://indianaiproduction.com/matplotlib-pie-chart/">Matplotlib Pie Chart &#8211; plt.pie() | Python Matplotlib Tutorial</a> appeared first on <a rel="nofollow" href="https://indianaiproduction.com">Indian AI Production</a>.</p>
]]></description>
										<content:encoded><![CDATA[
<h2 class="wp-block-heading">Matplotlib Pie Chart </h2>



<p>In this blog, we will work on how to draw a <strong>matplotlib pie chart</strong>? To draw pie char use plt.pie() function. The matplotkib plt.pie() function help to plot pie chart of given numeric data with labels. It also support different parameters which help to show better.</p>



<p><strong>Importing Library </strong></p>


<div class="wp-block-syntaxhighlighter-code "><pre class="brush: python; title: ; notranslate">
import matplotlib.pyplot as plt
</pre></div>


<h3 class="wp-block-heading">Plotting Matplotlib Pie Chart</h3>


<div class="wp-block-syntaxhighlighter-code "><pre class="brush: python; title: ; notranslate">
plt.pie(&#x5B;1]) # Plot pie chart of value &#x5B;1]
plt.show() # To show Pie chart
</pre></div>


<p><strong>Output >>></strong></p>



<div class="wp-block-image"><figure class="aligncenter is-resized"><img loading="lazy" decoding="async" src="https://i0.wp.com/indianaiproduction.com/wp-content/uploads/2019/07/Matplotlib-simple-pie-chart-1.png?resize=328%2C334&#038;ssl=1" alt="Matplotlib Simple pie Chart" class="wp-image-714" width="328" height="334" srcset="https://i0.wp.com/indianaiproduction.com/wp-content/uploads/2019/07/Matplotlib-simple-pie-chart-1.png?w=309&amp;ssl=1 309w, https://i0.wp.com/indianaiproduction.com/wp-content/uploads/2019/07/Matplotlib-simple-pie-chart-1.png?resize=295%2C300&amp;ssl=1 295w" sizes="(max-width: 328px) 100vw, 328px" data-recalc-dims="1" /><figcaption>Fig 1.1 &#8211; Matplotlib Simple pie Chart</figcaption></figure></div>



<p><strong>Importing Dataset</strong></p>


<div class="wp-block-syntaxhighlighter-code "><pre class="brush: python; title: ; notranslate">
classes = &#x5B;&quot;Python&quot;, 'R', 'Machine Learning', 'Artificial Intelligence', 
           'Data Sciece']
class1_students = &#x5B;45, 15, 35, 25, 30]
</pre></div>


<p>Plotting pie chart using real dataset.</p>


<div class="wp-block-syntaxhighlighter-code "><pre class="brush: python; title: ; notranslate">
plt.pie(class1_students, labels = classes)
plt.show()
</pre></div>


<p><strong>Output >>></strong></p>



<div class="wp-block-image"><figure class="aligncenter"><img loading="lazy" decoding="async" width="650" height="465" src="https://i0.wp.com/indianaiproduction.com/wp-content/uploads/2019/07/Matplotlib-pie-chart-using-dataset-2.png?resize=650%2C465&#038;ssl=1" alt="Matplotlib pie chart using dataset " class="wp-image-715" srcset="https://i0.wp.com/indianaiproduction.com/wp-content/uploads/2019/07/Matplotlib-pie-chart-using-dataset-2.png?w=650&amp;ssl=1 650w, https://i0.wp.com/indianaiproduction.com/wp-content/uploads/2019/07/Matplotlib-pie-chart-using-dataset-2.png?resize=300%2C215&amp;ssl=1 300w" sizes="(max-width: 650px) 100vw, 650px" data-recalc-dims="1" /><figcaption>Fig 1.2 &#8211; Matplotlib pie chart using dataset </figcaption></figure></div>



<p>Below are the different parameters of plt.pie() functions.</p>



<p><strong><span style="color:#e90f0f" class="tadv-color">Syntax:</span> <span style="color:#cf2e2e" class="tadv-color">plt.pie(</span></strong><br><span style="color:#00d084" class="tadv-color"><strong>     [&#8216;x&#8217;, <br>     &#8216;explode=None&#8217;, <br>     &#8216;labels=None&#8217;, <br>     &#8216;colors=None&#8217;, <br>     &#8216;autopct=None&#8217;, <br>     &#8216;pctdistance=0.6&#8217;, <br>     &#8216;shadow=False&#8217;, <br>     &#8216;labeldistance=1.1&#8217;, <br>     &#8216;startangle=None&#8217;, <br>     &#8216;radius=None&#8217;, <br>     &#8216;counterclock=True&#8217;, <br>     &#8216;wedgeprops=None&#8217;, <br>     &#8216;textprops=None&#8217;, <br>     &#8216;center=(0, 0)&#8217;, <br>     &#8216;frame=False&#8217;, <br>     &#8216;rotatelabels=False&#8217;, <br>     &#8216;*&#8217;, <br>     &#8216;data=None&#8217;],</strong></span><br><strong><span style="color:#cf2e2e" class="tadv-color"> )</span></strong></p>



<p>x : array-like<br> explode : array-like, optional, default: None<br> labels : list, optional, default: None<br> colors : array-like, optional, default: None<br> autopct : None (default), string, or function, optional<br> pctdistance : float, optional, default: 0.6<br> shadow : bool, optional, default: False<br> labeldistance : float, optional, default: 1.1<br> startangle : float, optional, default: None<br> radius : float, optional, default: None<br> counterclock : bool, optional, default: True<br> wedgeprops : dict, optional, default: None <br>         &#8212;- example, you can pass in wedgeprops = {&#8216;linewidth&#8217;: 3}<br> textprops : dict, optional, default: None<br> center :  list of float, optional, default: (0, 0)<br> frame : bool, optional, default: False<br> rotatelabels : bool, optional, default: False</p>



<p><strong>Plotting pie chart using different parameters. </strong></p>


<div class="wp-block-syntaxhighlighter-code "><pre class="brush: python; title: ; notranslate">
explode = &#x5B;0.03,0,0.1,0,0] # To slice the perticuler section
colors = &#x5B;&quot;c&quot;, 'b','r','y','g'] # Color of each section
textprops = {&quot;fontsize&quot;:15} # Font size of text in pie chart

plt.pie(class1_students, # Values
        labels = classes, # Labels for each sections
        explode = explode, # To slice the perticuler section
        colors =colors, # Color of each section
        autopct = &quot;%0.2f%%&quot;, # Show data in persentage for with 2 decimal point
        shadow = True, # Showing shadow of pie chart
        radius = 1.4, # Radius to increase or decrease the size of pie chart 
       startangle = 270, # Start angle of first section
        textprops =textprops) 

plt.show() # To show pie chart only
</pre></div>


<p><strong>Output >>></strong></p>



<div class="wp-block-image"><figure class="aligncenter"><img loading="lazy" decoding="async" width="652" height="465" src="https://i0.wp.com/indianaiproduction.com/wp-content/uploads/2019/07/Matplotlib-pie-chart-using-parameters-3.png?resize=652%2C465&#038;ssl=1" alt="Matplotlib pie chart using parameters" class="wp-image-716" srcset="https://i0.wp.com/indianaiproduction.com/wp-content/uploads/2019/07/Matplotlib-pie-chart-using-parameters-3.png?w=652&amp;ssl=1 652w, https://i0.wp.com/indianaiproduction.com/wp-content/uploads/2019/07/Matplotlib-pie-chart-using-parameters-3.png?resize=300%2C214&amp;ssl=1 300w" sizes="(max-width: 652px) 100vw, 652px" data-recalc-dims="1" /><figcaption>Fig 1.3 &#8211; Matplotlib pie chart using parameters</figcaption></figure></div>



<p><strong>Plotting pie chart using a legend &#8211; plt.legend()</strong></p>


<div class="wp-block-syntaxhighlighter-code "><pre class="brush: python; title: ; notranslate">
explode = &#x5B;0.03,0,0.1,0,0] # To slice the perticuler section
colors = &#x5B;&quot;c&quot;, 'b','r','y','g'] # Color of each section
textprops = {&quot;fontsize&quot;:15} # Font size of text in pie chart

plt.pie(class1_students, # Values
        labels = classes, # Labels for each sections
        explode = explode, # To slice the perticuler section
        colors =colors, # Color of each section
        autopct = &quot;%0.2f%%&quot;, # Show data in persentage for with 2 decimal point
        shadow = True, # Showing shadow of pie chart
        radius = 1.4, # Radius to increase or decrease the size of pie chart 
       startangle = 270, # Start angle of first section
        textprops =textprops) 
plt.legend() # To show legend
plt.show() # To show pie chart only
</pre></div>


<p><strong>Output >>> </strong></p>



<div class="wp-block-image"><figure class="aligncenter"><img loading="lazy" decoding="async" width="653" height="466" src="https://i0.wp.com/indianaiproduction.com/wp-content/uploads/2019/07/Matplotlib-pie-chart-using-legend-5.png?resize=653%2C466&#038;ssl=1" alt="Matplotlib pie chart using legend " class="wp-image-718" srcset="https://i0.wp.com/indianaiproduction.com/wp-content/uploads/2019/07/Matplotlib-pie-chart-using-legend-5.png?w=653&amp;ssl=1 653w, https://i0.wp.com/indianaiproduction.com/wp-content/uploads/2019/07/Matplotlib-pie-chart-using-legend-5.png?resize=300%2C214&amp;ssl=1 300w" sizes="(max-width: 653px) 100vw, 653px" data-recalc-dims="1" /><figcaption>Fig 1.4 -Matplotlib pie chart using legend </figcaption></figure></div>



<p><strong>Plotting pie chart using more parameters than above and width = 1.</strong></p>


<div class="wp-block-syntaxhighlighter-code "><pre class="brush: python; title: ; notranslate">
plt.figure(figsize = (3,2))
wedgeprops = {&quot;linewidth&quot;: 4, 'width':1, &quot;edgecolor&quot;:&quot;k&quot;} # Width = 1
plt.pie(
        class1_students, 
        labels = classes, 
        explode = explode, 
        colors = colors, 
        autopct = &quot;%0.2f%%&quot;, 
        pctdistance = 0.6, 
        shadow =True, 
        labeldistance = 1.6, 
        startangle = 270,
        radius = 1, 
        counterclock = True, 
        wedgeprops = wedgeprops,
        textprops = textprops,
        center=(2, 3),
        frame=True,
        rotatelabels=True
        ) 
plt.show()
</pre></div>


<p><strong>Output >>></strong></p>



<div class="wp-block-image"><figure class="aligncenter"><img loading="lazy" decoding="async" width="691" height="716" src="https://i0.wp.com/indianaiproduction.com/wp-content/uploads/2019/07/Matplotlib-pie-chart-using-more-parameters-4.png?resize=691%2C716&#038;ssl=1" alt="Matplotlib pie chart using more parameters" class="wp-image-717" srcset="https://i0.wp.com/indianaiproduction.com/wp-content/uploads/2019/07/Matplotlib-pie-chart-using-more-parameters-4.png?w=691&amp;ssl=1 691w, https://i0.wp.com/indianaiproduction.com/wp-content/uploads/2019/07/Matplotlib-pie-chart-using-more-parameters-4.png?resize=290%2C300&amp;ssl=1 290w" sizes="(max-width: 691px) 100vw, 691px" data-recalc-dims="1" /><figcaption>Fig 1.5 &#8211; Matplotlib pie chart using more parameters</figcaption></figure></div>



<p>Change the Value of width by 2,3,4 then you will gote below the pie charts.</p>



<div class="wp-block-image"><figure class="aligncenter is-resized"><img loading="lazy" decoding="async" src="https://i0.wp.com/indianaiproduction.com/wp-content/uploads/2019/07/Matplotlib-pie-chart-with-width-6.png?resize=521%2C540&#038;ssl=1" alt="" class="wp-image-719" width="521" height="540" srcset="https://i0.wp.com/indianaiproduction.com/wp-content/uploads/2019/07/Matplotlib-pie-chart-with-width-6.png?w=694&amp;ssl=1 694w, https://i0.wp.com/indianaiproduction.com/wp-content/uploads/2019/07/Matplotlib-pie-chart-with-width-6.png?resize=289%2C300&amp;ssl=1 289w" sizes="(max-width: 521px) 100vw, 521px" data-recalc-dims="1" /><figcaption> Fig 1.6 &#8211; Matplotlib pie chart with a width value 2 </figcaption></figure></div>



<div class="wp-block-image"><figure class="aligncenter is-resized"><img loading="lazy" decoding="async" src="https://i0.wp.com/indianaiproduction.com/wp-content/uploads/2019/07/Matplotlib-pie-chart-with-width-7-1.png?resize=548%2C537&#038;ssl=1" alt="" class="wp-image-721" width="548" height="537" srcset="https://i0.wp.com/indianaiproduction.com/wp-content/uploads/2019/07/Matplotlib-pie-chart-with-width-7-1.png?w=730&amp;ssl=1 730w, https://i0.wp.com/indianaiproduction.com/wp-content/uploads/2019/07/Matplotlib-pie-chart-with-width-7-1.png?resize=300%2C294&amp;ssl=1 300w" sizes="(max-width: 548px) 100vw, 548px" data-recalc-dims="1" /><figcaption> Fig 1.7 &#8211; Matplotlib pie chart with width value 3</figcaption></figure></div>



<p>Plotting another pie charts for fun.</p>


<div class="wp-block-syntaxhighlighter-code "><pre class="brush: python; title: ; notranslate">
import numpy as np
plt.figure(figsize=(7,4))
#plt.figure(figsize=(16,9)

colors = &#x5B;'r','w','r','w','r','w','r','w','r','w','r','w','r','w','r','w','r','w','r','w']
labels = np.ones(20)
#labels = &#x5B;1.0,1.0,1.0,1.0,1.0,.........,1.0]

plt.pie(&#x5B;1], colors=&quot;k&quot;, radius = 2.05)
plt.pie(labels, colors=colors, radius = 2.0)

plt.pie(&#x5B;1], colors=&quot;g&quot;, radius = 1.8)
plt.pie(&#x5B;1], colors=&quot;y&quot;, radius = 1.6)
plt.pie(&#x5B;1], colors=&quot;c&quot;, radius = 1.3)
plt.pie(&#x5B;1], colors=&quot;b&quot;, radius = 1.1)
plt.pie(&#x5B;1], colors=&quot;m&quot;, radius = 0.9)

plt.pie(&#x5B;1], colors=&quot;b&quot;, radius = 0.31)
plt.pie(labels, colors=colors, radius = 0.3)

plt.pie(&#x5B;1], colors=&quot;w&quot;, radius = 0.2)
plt.pie(&#x5B;1], colors=&quot;k&quot;, radius = 0.1)

plt.show()
</pre></div>


<p><strong>Output >>></strong></p>



<figure class="wp-block-image"><img loading="lazy" decoding="async" width="692" height="692" src="https://i0.wp.com/indianaiproduction.com/wp-content/uploads/2019/07/Matplotlib-pie-charts-8.png?resize=692%2C692&#038;ssl=1" alt="" class="wp-image-722" srcset="https://i0.wp.com/indianaiproduction.com/wp-content/uploads/2019/07/Matplotlib-pie-charts-8.png?w=692&amp;ssl=1 692w, https://i0.wp.com/indianaiproduction.com/wp-content/uploads/2019/07/Matplotlib-pie-charts-8.png?resize=150%2C150&amp;ssl=1 150w, https://i0.wp.com/indianaiproduction.com/wp-content/uploads/2019/07/Matplotlib-pie-charts-8.png?resize=300%2C300&amp;ssl=1 300w" sizes="(max-width: 692px) 100vw, 692px" data-recalc-dims="1" /><figcaption> Fig 1.8 &#8211; Matplotlib pie charts</figcaption></figure>



<h3 class="wp-block-heading">Conclusion</h3>



<p>In the <strong>matplotlib plt.pie chart</strong> blog, we learn how to plot one and multiple pie charts with a real-time example using the <strong>plt.pie()</strong> method. Along with that used different method and different parameter. We suggest you make your hand dirty with each and every parameter of the above methods. This is the best coding practice. After completion of the <a rel="noreferrer noopener" href="https://indianaiproduction.com/python-matplotlib-tutorial/" target="_blank">matplotlib tutorial</a> jump on Seaborn.</p>



<p>Download Jupyter file of matplotlib bar chart source code</p>


<div class="su-button-center"><a href="https://drive.google.com/file/d/1Ructll4E8g0QZHp3tMsD9y-bh6-e3DmH/view?usp=sharing" class="su-button su-button-style-3d" style="color:#FFFFFF;background-color:#38bb04;border-color:#2d9604;border-radius:24px" target="_self"><span style="color:#FFFFFF;padding:5px 14px;font-size:12px;line-height:18px;border-color:#74d050;border-radius:24px;text-shadow:none"><i class="sui sui-cloud-download" style="font-size:12px;color:#FFFFFF"></i> Matplotlib Bar Char source code</span></a></div>



<p>

 Visit the official site of <a href="http://www.matplotlib.org/">matplotlib.org</a></p>
<p>The post <a rel="nofollow" href="https://indianaiproduction.com/matplotlib-pie-chart/">Matplotlib Pie Chart &#8211; plt.pie() | Python Matplotlib Tutorial</a> appeared first on <a rel="nofollow" href="https://indianaiproduction.com">Indian AI Production</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://indianaiproduction.com/matplotlib-pie-chart/feed/</wfw:commentRss>
			<slash:comments>1</slash:comments>
		
		
		<post-id xmlns="com-wordpress:feed-additions:1">712</post-id>	</item>
		<item>
		<title>Matplotlib Bar Chart &#8211; Python Matplotlib Tutorial</title>
		<link>https://indianaiproduction.com/matplotlib-bar-chart/</link>
					<comments>https://indianaiproduction.com/matplotlib-bar-chart/#comments</comments>
		
		<dc:creator><![CDATA[Indian AI Production]]></dc:creator>
		<pubDate>Mon, 08 Jul 2019 18:10:26 +0000</pubDate>
				<category><![CDATA[Python Matplotlib Tutorial]]></category>
		<category><![CDATA[bar chart matplotlib]]></category>
		<category><![CDATA[bar charts]]></category>
		<category><![CDATA[Matplotlib Bar Chart]]></category>
		<category><![CDATA[plt.bar()]]></category>
		<category><![CDATA[plt.barh()]]></category>
		<guid isPermaLink="false">https://indianaiproduction.com/?p=664</guid>

					<description><![CDATA[<p>Matplotlib Bar Chart To visualize value associated with categorical data in&#160;the bar format use matplotlib bar chart plt.bar() or plt.barh() methods. Importing Libary to Plot Bar Chart Importing Data set to plot Bar Chart This dataset of &#8220;Indian Artificial Intelligence Production Class&#8221; (IAIP).&#160; Instead of it use your business dataset. Plot Bar Chart with a &#8230;</p>
<p class="read-more"> <a class="" href="https://indianaiproduction.com/matplotlib-bar-chart/"> <span class="screen-reader-text">Matplotlib Bar Chart &#8211; Python Matplotlib Tutorial</span> Read More &#187;</a></p>
<p>The post <a rel="nofollow" href="https://indianaiproduction.com/matplotlib-bar-chart/">Matplotlib Bar Chart &#8211; Python Matplotlib Tutorial</a> appeared first on <a rel="nofollow" href="https://indianaiproduction.com">Indian AI Production</a>.</p>
]]></description>
										<content:encoded><![CDATA[
<h2>Matplotlib Bar Chart</h2>
<p>To visualize value associated with categorical data in&nbsp;the bar format use <strong>matplotlib bar chart</strong> plt.bar() or plt.barh() methods.</p>



<h3>Importing Libary to Plot Bar Chart</h3>


<div class="wp-block-syntaxhighlighter-code "><pre class="brush: python; title: ; notranslate">
import matplotlib.pyplot as plt
import numpy as np
from matplotlib import style
</pre></div>


<h3>Importing Data set to plot Bar Chart</h3>
<p>This dataset of &#8220;Indian Artificial Intelligence Production Class&#8221; (IAIP).&nbsp; Instead of it use your business dataset.</p>


<div class="wp-block-syntaxhighlighter-code "><pre class="brush: python; title: ; notranslate">
# Dataset of 'Indian Artificial Intelligence Production (IAIP) Class&quot;

#classes = &#x5B;&quot;Python&quot;, &quot;R&quot;, &quot;Artificial Intelligence&quot;, &quot;Machine Learning&quot;, &quot;Data Science&quot;]

classes = &#x5B;&quot;Python&quot;, &quot;R&quot;, &quot;AI&quot;, &quot;ML&quot;, &quot;DS&quot;]
class1_students = &#x5B;30, 10, 20, 25, 10] # out of 100 student in each class
class2_students = &#x5B;40, 5, 20, 20, 10]
class3_students = &#x5B;35, 5, 30, 15, 15]
</pre></div>


<h3>Plot Bar Chart with a different way</h3>
<p>To plot bar chart using the matplotlib <a href="https://python.org" target="_blank" rel="noopener noreferrer">python</a> library, use plt.bar() or plt.barh() methods.</p>
<p><span style="color: #ff0000;"><strong>Syntax: <span style="color: #800000;">plt.bar(</span></strong></span><br><span style="color: #ff0000;"><strong>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #008000;">x,</span></strong></span><br><span style="color: #008000;"><strong>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;height,</strong></span><br><span style="color: #008000;"><strong>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;width=0.8,</strong></span><br><span style="color: #008000;"><strong>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;bottom=None,</strong></span><br><span style="color: #008000;"><strong>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;*,</strong></span><br><span style="color: #008000;"><strong>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;align=&#8217;center&#8217;,</strong></span><br><span style="color: #008000;"><strong>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;data=None,</strong></span><br><span style="color: #008000;"><strong>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;**kwargs,</strong></span><br><span style="color: #ff0000;"><strong>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #800000;">&nbsp;)</span></strong></span></p>
<h4>Parameters</h4>
<p>&#8212;&#8212;&#8212;-<br>x : sequence of scalars<br>height : scalar or sequence of scalars<br>width : scalar or array-like, optional &#8230;&#8230;.(default: 0.8).<br>bottom : scalar or array-like, optional<br>align : {&#8216;center&#8217;, &#8216;edge&#8217;}, optional, &#8230;&#8230;&#8230;.default: &#8216;center&#8217;</p>
<h4><br>Other Parameters<br>&#8212;&#8212;&#8212;&#8212;&#8212;-</h4>
<p>color : scalar or array-like, optional<br>edgecolor : scalar or array-like, optional<br>linewidth : scalar or array-like, optional<br>tick_label : string or array-like, optional &#8230;&#8230;. name of Bar<br>xerr, yerr : scalar or array-like of shape(N,) or shape(2,N), optional<br>ecolor : scalar or array-like, optional, default: &#8216;black&#8217;<br>capsize : scalar, optional<br>error_kw : dict, optional<br>log : bool, optional, default: False<br>orientation : {&#8216;vertical&#8217;, &#8216;horizontal&#8217;}, optional</p>
<p><br>See also<br>&#8212;&#8212;&#8211;<br>barh: Plot a horizontal bar plot.</p>
<p>Other optional kwargs:</p>
<p>agg_filter: a filter function, which takes a (m, n, 3) float array and a dpi value, and returns a (m, n, 3) array <br>===== alpha: float or None<br>animated: bool<br>antialiased: unknown<br>capstyle: {&#8216;butt&#8217;, &#8217;round&#8217;, &#8216;projecting&#8217;}<br>clip_box: `.Bbox`<br>clip_on: bool<br>clip_path: [(`~matplotlib.path.Path`, `.Transform`) | `.Patch` | None] <br>===== color: color<br>contains: callable<br>===== edgecolor: color or None or &#8216;auto&#8217;<br>===== facecolor: color or None<br>===== figure: `.Figure`<br>fill: bool<br>gid: str<br>hatch: {&#8216;/&#8217;, &#8216;\\&#8217;, &#8216;|&#8217;, &#8216;-&#8216;, &#8216;+&#8217;, &#8216;x&#8217;, &#8216;o&#8217;, &#8216;O&#8217;, &#8216;.&#8217;, &#8216;*&#8217;}<br>in_layout: bool<br>joinstyle: {&#8216;miter&#8217;, &#8217;round&#8217;, &#8216;bevel&#8217;}<br>===== label: object<br>===== linestyle: {&#8216;-&#8216;, &#8216;&#8211;&#8216;, &#8216;-.&#8217;, &#8216;:&#8217;, &#8221;, (offset, on-off-seq), &#8230;}<br>===== linewidth: float or None for default <br>path_effects: `.AbstractPathEffect`<br>picker: None or bool or float or callable<br>rasterized: bool or None<br>sketch_params: (scale: float, length: float, randomness: float) <br>snap: bool or None<br>transform: `.Transform`<br>url: str<br>===== visible: bool<br>zorder: float</p>


<div class="wp-block-syntaxhighlighter-code "><pre class="brush: python; title: ; notranslate">
plt.bar(classes, class1_students) # Plot vertical Bar Chart
</pre></div>


<p><strong>Output &gt;&gt;&gt;</strong></p>
<figure id="attachment_667" aria-describedby="caption-attachment-667" style="width: 469px" class="wp-caption aligncenter"><img loading="lazy" decoding="async" class="size-full wp-image-667" src="https://i0.wp.com/indianaiproduction.com/wp-content/uploads/2019/07/Matplotlib-Bar-Chart-1.png?resize=469%2C314&#038;ssl=1" alt="Matplotlib Bar Chart - 1" width="469" height="314" srcset="https://i0.wp.com/indianaiproduction.com/wp-content/uploads/2019/07/Matplotlib-Bar-Chart-1.png?w=469&amp;ssl=1 469w, https://i0.wp.com/indianaiproduction.com/wp-content/uploads/2019/07/Matplotlib-Bar-Chart-1.png?resize=300%2C201&amp;ssl=1 300w" sizes="(max-width: 469px) 100vw, 469px" data-recalc-dims="1" /><figcaption id="caption-attachment-667" class="wp-caption-text">Fig 1.1 &#8211; Matplotlib Vertical Bar Chart</figcaption></figure>


<div class="wp-block-syntaxhighlighter-code "><pre class="brush: python; title: ; notranslate">
plt.barh(classes, class1_students) # Plot horizontal bar chart 
</pre></div>


<p><strong>Output &gt;&gt;&gt;</strong></p>
<figure id="attachment_668" aria-describedby="caption-attachment-668" style="width: 473px" class="wp-caption aligncenter"><img loading="lazy" decoding="async" class="size-full wp-image-668" src="https://i0.wp.com/indianaiproduction.com/wp-content/uploads/2019/07/Matplotlib-Horizontal-Bar-Chart-2.png?resize=473%2C314&#038;ssl=1" alt="Matplotlib Horizontal Bar Chart - 2" width="473" height="314" srcset="https://i0.wp.com/indianaiproduction.com/wp-content/uploads/2019/07/Matplotlib-Horizontal-Bar-Chart-2.png?w=473&amp;ssl=1 473w, https://i0.wp.com/indianaiproduction.com/wp-content/uploads/2019/07/Matplotlib-Horizontal-Bar-Chart-2.png?resize=300%2C199&amp;ssl=1 300w" sizes="(max-width: 473px) 100vw, 473px" data-recalc-dims="1" /><figcaption id="caption-attachment-668" class="wp-caption-text">Fig 1.2 &#8211; Matplotlib Horizontal Bar Chart</figcaption></figure>
<p><span style="font-size: 14pt;"><strong>Use multiple parameters of plt.bar() method</strong></span></p>


<div class="wp-block-syntaxhighlighter-code "><pre class="brush: python; title: ; notranslate">
plt.bar(classes, class1_students, width = 0.2, align = &quot;edge&quot;, color = &quot;y&quot;,
       edgecolor = &quot;m&quot;, linewidth = 5, alpha = 0.9, linestyle = &quot;--&quot;,
       label =&quot; Class 1 Students&quot;, visible=False)
#visible = True ## bar Chart will hide 
</pre></div>


<p><strong>Output &gt;&gt;&gt;&nbsp;</strong></p>
<figure id="attachment_669" aria-describedby="caption-attachment-669" style="width: 470px" class="wp-caption aligncenter"><img loading="lazy" decoding="async" class="size-full wp-image-669" src="https://i0.wp.com/indianaiproduction.com/wp-content/uploads/2019/07/Matplotlib-Bar-Chart-with-multiple-parameters-3.png?resize=470%2C327&#038;ssl=1" alt="Matplotlib Bar Chart with multiple parameters - 3" width="470" height="327" srcset="https://i0.wp.com/indianaiproduction.com/wp-content/uploads/2019/07/Matplotlib-Bar-Chart-with-multiple-parameters-3.png?w=470&amp;ssl=1 470w, https://i0.wp.com/indianaiproduction.com/wp-content/uploads/2019/07/Matplotlib-Bar-Chart-with-multiple-parameters-3.png?resize=300%2C209&amp;ssl=1 300w" sizes="(max-width: 470px) 100vw, 470px" data-recalc-dims="1" /><figcaption id="caption-attachment-669" class="wp-caption-text">Fig 1.3 &#8211; Matplotlib Vertical Bar Chart with multiple parameters</figcaption></figure>
<p>Increase figure size and use style.</p>


<div class="wp-block-syntaxhighlighter-code "><pre class="brush: python; title: ; notranslate">
style.use(&quot;ggplot&quot;) 
plt.figure(figsize=(16,9)) # figure size with ratio 16:9
plt.bar(classes, class1_students, width = 0.6, align = &quot;edge&quot;, color = &quot;k&quot;,
       edgecolor = &quot;m&quot;, linewidth = 5, alpha = 0.9, linestyle = &quot;--&quot;,
       label =&quot; Class 1 Students&quot;) #visible=False
</pre></div>


<p><strong>Output &gt;&gt;&gt;</strong></p>
<figure id="attachment_670" aria-describedby="caption-attachment-670" style="width: 1023px" class="wp-caption aligncenter"><img loading="lazy" decoding="async" class="size-full wp-image-670" src="https://i0.wp.com/indianaiproduction.com/wp-content/uploads/2019/07/Matplotlib-Vertical-Bar-Chart-with-multiple-parameters-4.png?resize=1023%2C579&#038;ssl=1" alt="Matplotlib Vertical Bar Chart with multiple parameters - 4" width="1023" height="579" srcset="https://i0.wp.com/indianaiproduction.com/wp-content/uploads/2019/07/Matplotlib-Vertical-Bar-Chart-with-multiple-parameters-4.png?w=1023&amp;ssl=1 1023w, https://i0.wp.com/indianaiproduction.com/wp-content/uploads/2019/07/Matplotlib-Vertical-Bar-Chart-with-multiple-parameters-4.png?resize=300%2C170&amp;ssl=1 300w, https://i0.wp.com/indianaiproduction.com/wp-content/uploads/2019/07/Matplotlib-Vertical-Bar-Chart-with-multiple-parameters-4.png?resize=768%2C435&amp;ssl=1 768w" sizes="(max-width: 1023px) 100vw, 1023px" data-recalc-dims="1" /><figcaption id="caption-attachment-670" class="wp-caption-text">Fig 1.4 &#8211; Matplotlib Vertical Bar Chart with multiple parameters</figcaption></figure>
<p>Plot horizontal bar chart with the above specification.&nbsp;</p>


<div class="wp-block-syntaxhighlighter-code "><pre class="brush: python; title: ; notranslate">
plt.figure(figsize=(16,9))
plt.barh(classes, class1_students,  align = &quot;edge&quot;, color = &quot;k&quot;,
       edgecolor = &quot;m&quot;, linewidth = 5, alpha = 0.9, linestyle = &quot;--&quot;,
       label =&quot; Class 1 Students&quot;) #visible=False
</pre></div>


<p><strong>Output &gt;&gt;&gt;</strong></p>
<figure id="attachment_671" aria-describedby="caption-attachment-671" style="width: 1049px" class="wp-caption aligncenter"><img loading="lazy" decoding="async" class="size-full wp-image-671" src="https://i0.wp.com/indianaiproduction.com/wp-content/uploads/2019/07/Matplotlib-Horizontal-Bar-Chart-with-multiple-parameters-5.png?resize=1049%2C579&#038;ssl=1" alt="Matplotlib Horizontal Bar Chart with multiple parameters - 5" width="1049" height="579" srcset="https://i0.wp.com/indianaiproduction.com/wp-content/uploads/2019/07/Matplotlib-Horizontal-Bar-Chart-with-multiple-parameters-5.png?w=1049&amp;ssl=1 1049w, https://i0.wp.com/indianaiproduction.com/wp-content/uploads/2019/07/Matplotlib-Horizontal-Bar-Chart-with-multiple-parameters-5.png?resize=300%2C166&amp;ssl=1 300w, https://i0.wp.com/indianaiproduction.com/wp-content/uploads/2019/07/Matplotlib-Horizontal-Bar-Chart-with-multiple-parameters-5.png?resize=768%2C424&amp;ssl=1 768w, https://i0.wp.com/indianaiproduction.com/wp-content/uploads/2019/07/Matplotlib-Horizontal-Bar-Chart-with-multiple-parameters-5.png?resize=1024%2C565&amp;ssl=1 1024w" sizes="(max-width: 1049px) 100vw, 1049px" data-recalc-dims="1" /><figcaption id="caption-attachment-671" class="wp-caption-text">Fig 1.5 &#8211; Matplotlib Horizontal Bar Chart with multiple parameters</figcaption></figure>



<p>Decorating bar chart using multiple functions.</p>


<div class="wp-block-syntaxhighlighter-code "><pre class="brush: python; title: ; notranslate">
plt.figure(figsize=(16,9))
plt.bar(classes, class1_students, width = 0.6, align = &quot;edge&quot;, color = &quot;k&quot;,
       edgecolor = &quot;m&quot;, linewidth = 5, alpha = 0.9, linestyle = &quot;--&quot;,
       label =&quot; Class 1 Students&quot;) #visible=False

plt.title(&quot;Bar Chart of IAIP Class&quot;, fontsize = 18)
plt.xlabel(&quot;Classes&quot;,fontsize = 15)
plt.ylabel(&quot;No. of Students&quot;, fontsize = 15)
plt.show()
</pre></div>


<p><strong>Output &gt;&gt;&gt;</strong></p>
<figure id="attachment_672" aria-describedby="caption-attachment-672" style="width: 975px" class="wp-caption aligncenter"><img loading="lazy" decoding="async" class="size-full wp-image-672" src="https://i0.wp.com/indianaiproduction.com/wp-content/uploads/2019/07/Matplotlib-Horizontal-Bar-Chart-with-multiple-functions-6.png?resize=975%2C579&#038;ssl=1" alt="Matplotlib Horizontal Bar Chart with multiple functions- 6" width="975" height="579" srcset="https://i0.wp.com/indianaiproduction.com/wp-content/uploads/2019/07/Matplotlib-Horizontal-Bar-Chart-with-multiple-functions-6.png?w=975&amp;ssl=1 975w, https://i0.wp.com/indianaiproduction.com/wp-content/uploads/2019/07/Matplotlib-Horizontal-Bar-Chart-with-multiple-functions-6.png?resize=300%2C178&amp;ssl=1 300w, https://i0.wp.com/indianaiproduction.com/wp-content/uploads/2019/07/Matplotlib-Horizontal-Bar-Chart-with-multiple-functions-6.png?resize=768%2C456&amp;ssl=1 768w" sizes="(max-width: 975px) 100vw, 975px" data-recalc-dims="1" /><figcaption id="caption-attachment-672" class="wp-caption-text">Fig 1.6 &#8211; Matplotlib Horizontal Bar Chart with multiple functions</figcaption></figure>
<p>Trying to plot two bar charts with a different dataset.</p>


<div class="wp-block-syntaxhighlighter-code "><pre class="brush: python; title: ; notranslate">
plt.figure(figsize=(16,9))

plt.bar(classes, class1_students, width = 0.2, color = &quot;b&quot;,
        label =&quot; Class 1 Students&quot;) #visible=False

plt.bar(classes, class2_students, width = 0.2, color = &quot;g&quot;,
        label =&quot; Class 2 Students&quot;) 

plt.title(&quot;Bar Chart of IAIP Class&quot;, fontsize = 18)
plt.xlabel(&quot;Classes&quot;,fontsize = 15)
plt.ylabel(&quot;No. of Students&quot;, fontsize = 15)
plt.show()
</pre></div>


<p><strong>Output &gt;&gt;&gt;</strong></p>
<figure id="attachment_673" aria-describedby="caption-attachment-673" style="width: 975px" class="wp-caption aligncenter"><img loading="lazy" decoding="async" class="size-full wp-image-673" src="https://i0.wp.com/indianaiproduction.com/wp-content/uploads/2019/07/Matplotlib-two-Bar-Chart-7.png?resize=975%2C579&#038;ssl=1" alt="Matplotlib two Bar Chart - 7" width="975" height="579" srcset="https://i0.wp.com/indianaiproduction.com/wp-content/uploads/2019/07/Matplotlib-two-Bar-Chart-7.png?w=975&amp;ssl=1 975w, https://i0.wp.com/indianaiproduction.com/wp-content/uploads/2019/07/Matplotlib-two-Bar-Chart-7.png?resize=300%2C178&amp;ssl=1 300w, https://i0.wp.com/indianaiproduction.com/wp-content/uploads/2019/07/Matplotlib-two-Bar-Chart-7.png?resize=768%2C456&amp;ssl=1 768w" sizes="(max-width: 975px) 100vw, 975px" data-recalc-dims="1" /><figcaption id="caption-attachment-673" class="wp-caption-text">Fig 1.7 &#8211; Matplotlib two Bar Chart</figcaption></figure>
<p>The above code not generating two bar charts in one figure but they are overlapping. So use the below code to plot multiple bar charts. In below chart plot three bar charts using three different datasets.</p>


<div class="wp-block-syntaxhighlighter-code "><pre class="brush: python; title: ; notranslate">
plt.figure(figsize=(16,9))

classes_index = np.arange(len(classes))

width = 0.2

plt.bar(classes_index, class1_students, width , color = &quot;b&quot;,
        label =&quot; Class 1 Students&quot;) #visible=False

plt.bar(classes_index + width, class2_students, width , color = &quot;g&quot;,
        label =&quot; Class 2 Students&quot;) 

plt.bar(classes_index + width + width, class3_students, width , color = &quot;y&quot;,
        label =&quot; Class 2 Students&quot;) 

plt.xticks(classes_index + width, classes, rotation = 20)
plt.title(&quot;Bar Chart of IAIP Class&quot;, fontsize = 18)
plt.xlabel(&quot;Classes&quot;,fontsize = 15)
plt.ylabel(&quot;No. of Students&quot;, fontsize = 15)
plt.show()
</pre></div>


<p><strong>Output &gt;&gt;&gt;</strong></p>
<figure id="attachment_675" aria-describedby="caption-attachment-675" style="width: 956px" class="wp-caption aligncenter"><img loading="lazy" decoding="async" class="size-full wp-image-675" src="https://i0.wp.com/indianaiproduction.com/wp-content/uploads/2019/07/Matplotlib-Three-Bar-Chart-7.png?resize=956%2C579&#038;ssl=1" alt="Matplotlib Three Bar Chart - 7" width="956" height="579" srcset="https://i0.wp.com/indianaiproduction.com/wp-content/uploads/2019/07/Matplotlib-Three-Bar-Chart-7.png?w=956&amp;ssl=1 956w, https://i0.wp.com/indianaiproduction.com/wp-content/uploads/2019/07/Matplotlib-Three-Bar-Chart-7.png?resize=300%2C182&amp;ssl=1 300w, https://i0.wp.com/indianaiproduction.com/wp-content/uploads/2019/07/Matplotlib-Three-Bar-Chart-7.png?resize=768%2C465&amp;ssl=1 768w" sizes="(max-width: 956px) 100vw, 956px" data-recalc-dims="1" /><figcaption id="caption-attachment-675" class="wp-caption-text">Fig 1.8 &#8211; Matplotlib Three Bar Chart</figcaption></figure>
<p>Plot Matplotlib Horizontal bar chart with the above specification.</p>


<div class="wp-block-syntaxhighlighter-code "><pre class="brush: python; title: ; notranslate">
plt.figure(figsize=(16,9))

classes_index = np.arange(len(classes))

width = 0.2

plt.barh(classes_index, class1_students, width , color = &quot;b&quot;,
        label =&quot; Class 1 Students&quot;) #visible=False

plt.barh(classes_index + width, class2_students, width , color = &quot;g&quot;,
        label =&quot; Class 2 Students&quot;) 

plt.barh(classes_index + width + width, class3_students, width , color = &quot;y&quot;,
        label =&quot; Class 3 Students&quot;) 

plt.yticks(classes_index + width, classes, rotation = 20)
plt.title(&quot;Bar Chart of IAIP Class&quot;, fontsize = 18)
plt.ylabel(&quot;Classes&quot;,fontsize = 15)
plt.xlabel(&quot;No. of Students&quot;, fontsize = 15)
plt.legend()
plt.show()
</pre></div>


<p><strong>Output &gt;&gt;&gt;</strong></p>
<figure id="attachment_676" aria-describedby="caption-attachment-676" style="width: 998px" class="wp-caption aligncenter"><img loading="lazy" decoding="async" class="size-full wp-image-676" src="https://i0.wp.com/indianaiproduction.com/wp-content/uploads/2019/07/Matplotlib-Three-Horizontal-Bar-Chart-9.png?resize=998%2C578&#038;ssl=1" alt="Matplotlib Three Horizontal Bar Chart - 9" width="998" height="578" srcset="https://i0.wp.com/indianaiproduction.com/wp-content/uploads/2019/07/Matplotlib-Three-Horizontal-Bar-Chart-9.png?w=998&amp;ssl=1 998w, https://i0.wp.com/indianaiproduction.com/wp-content/uploads/2019/07/Matplotlib-Three-Horizontal-Bar-Chart-9.png?resize=300%2C174&amp;ssl=1 300w, https://i0.wp.com/indianaiproduction.com/wp-content/uploads/2019/07/Matplotlib-Three-Horizontal-Bar-Chart-9.png?resize=768%2C445&amp;ssl=1 768w" sizes="(max-width: 998px) 100vw, 998px" data-recalc-dims="1" /><figcaption id="caption-attachment-676" class="wp-caption-text">Fig 1.9 &#8211; Matplotlib Three Horizontal Bar Chart</figcaption></figure>



<h3>Conclusion</h3>
<p>In the <strong>matplotlib bar chart blog</strong>, we learn how to plot one and multiple bar charts with a real-time example using <strong>plt.bar()</strong> and <strong>plt.barh()</strong> methods. Along with that used different method and different parameter. We suggest you make your hand dirty with each and every parameter of the above methods. This is the best coding practice. After completion of the <a href="https://indianaiproduction.com/python-matplotlib-tutorial/" target="_blank" rel="noopener noreferrer">matplotlib tutorial</a>&nbsp;jump on Seaborn.</p>



<p>Download Jupyter file of matplotlib bar chart source code</p>


<div class="su-button-center"><a href="https://drive.google.com/file/d/1cksiOfxu4Q-RP6IJfX-smm1AGd3pyDoF/view?usp=sharing" class="su-button su-button-style-3d" style="color:#FFFFFF;background-color:#38bb04;border-color:#2d9604;border-radius:24px" target="_self"><span style="color:#FFFFFF;padding:5px 14px;font-size:12px;line-height:18px;border-color:#74d050;border-radius:24px;text-shadow:none"><i class="sui sui-cloud-download" style="font-size:12px;color:#FFFFFF"></i> Matplotlib Bar Char source code</span></a></div>



<p> Visit to the official site of <a href="http://www.matplotlib.org">matplotlib.org</a></p>
<p>The post <a rel="nofollow" href="https://indianaiproduction.com/matplotlib-bar-chart/">Matplotlib Bar Chart &#8211; Python Matplotlib Tutorial</a> appeared first on <a rel="nofollow" href="https://indianaiproduction.com">Indian AI Production</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://indianaiproduction.com/matplotlib-bar-chart/feed/</wfw:commentRss>
			<slash:comments>1</slash:comments>
		
		
		<post-id xmlns="com-wordpress:feed-additions:1">664</post-id>	</item>
		<item>
		<title>Matplotlib Histogram &#8211; Python Matplotlib Tutorial</title>
		<link>https://indianaiproduction.com/matplotlib-histogram/</link>
					<comments>https://indianaiproduction.com/matplotlib-histogram/#respond</comments>
		
		<dc:creator><![CDATA[Indian AI Production]]></dc:creator>
		<pubDate>Fri, 28 Jun 2019 14:03:06 +0000</pubDate>
				<category><![CDATA[Python Matplotlib Tutorial]]></category>
		<category><![CDATA[histogram]]></category>
		<category><![CDATA[matplotlib histogram]]></category>
		<category><![CDATA[python histogram]]></category>
		<category><![CDATA[python matplotlib histogram]]></category>
		<guid isPermaLink="false">https://indianaiproduction.com/?p=551</guid>

					<description><![CDATA[<p>Python Matplotlib Histogram Matplotlib histogram is a representation of numeric data in the form of a rectangle bar. Each bar shows some data,  which belong to different categories. To plot histogram using python matplotlib library need plt.hist() method. Syntax: plt.hist(x,bins=None,range=None,density=None,weights=None,cumulative=False,bottom=None,histtype=&#8217;bar&#8217;,align=&#8217;mid&#8217;,orientation=&#8217;vertical&#8217;,rwidth=None,log=False,color=None,label=None,stacked=False,normed=None,*,data=None,**kwargs,) The plt.hist() method has lots of parameter, So we are going to cover some of &#8230;</p>
<p class="read-more"> <a class="" href="https://indianaiproduction.com/matplotlib-histogram/"> <span class="screen-reader-text">Matplotlib Histogram &#8211; Python Matplotlib Tutorial</span> Read More &#187;</a></p>
<p>The post <a rel="nofollow" href="https://indianaiproduction.com/matplotlib-histogram/">Matplotlib Histogram &#8211; Python Matplotlib Tutorial</a> appeared first on <a rel="nofollow" href="https://indianaiproduction.com">Indian AI Production</a>.</p>
]]></description>
										<content:encoded><![CDATA[
<h2>Python Matplotlib Histogram</h2>
<p><strong>Matplotlib histogram</strong> is a representation of numeric data in the form of a rectangle bar. Each bar shows some data,  which belong to different categories. To plot histogram using python matplotlib library need <strong>plt.hist()</strong> method.</p>
<p><strong><span style="color: #ff0000;">Syntax:</span> <span style="color: #800000;">plt.hist(</span></strong><br /><strong><span style="color: #008000;">x,</span></strong><br /><strong><span style="color: #008000;">bins=None,</span></strong><br /><strong>r<span style="color: #008000;">ange=None,</span></strong><br /><strong><span style="color: #008000;">density=None,</span></strong><br /><strong><span style="color: #008000;">weights=None,</span></strong><br /><strong><span style="color: #008000;">cumulative=False,</span></strong><br /><strong><span style="color: #008000;">bottom=None,</span></strong><br /><strong><span style="color: #008000;">histtype=&#8217;bar&#8217;,</span></strong><br /><strong><span style="color: #008000;">align=&#8217;mid&#8217;,</span></strong><br /><strong><span style="color: #008000;">orientation=&#8217;vertical&#8217;,</span></strong><br /><strong><span style="color: #008000;">rwidth=None,</span></strong><br /><strong><span style="color: #008000;">log=False,</span></strong><br /><strong><span style="color: #008000;">color=None,</span></strong><br /><strong><span style="color: #008000;">label=None,</span></strong><br /><strong><span style="color: #008000;">stacked=False,</span></strong><br /><strong><span style="color: #008000;">normed=None,</span></strong><br /><strong><span style="color: #008000;">*,</span></strong><br /><strong><span style="color: #008000;">data=None,</span></strong><br /><strong><span style="color: #008000;">**kwargs,</span></strong><br /><strong><span style="color: #800000;">)</span></strong></p>
<p>The <strong>plt.hist()</strong> method has lots of parameter, So we are going to cover some of these. Which is most important but you have to try each and every one to best practice.</p>
<h4>Importing Packages</h4>


<div class="wp-block-syntaxhighlighter-code "><pre class="brush: python; title: ; notranslate">
import matplotlib.pyplot as plt
import numpy as np
import random
</pre></div>


<h4>Generate Data</h4>


<div class="wp-block-syntaxhighlighter-code "><pre class="brush: python; title: ; notranslate">
ml_students_age = np.random.randint(18,45, (100))
py_students_age = np.random.randint(15,40, (100))
</pre></div>


<h4>Printing Generated Data</h4>


<div class="wp-block-syntaxhighlighter-code "><pre class="brush: python; title: ; notranslate">
print(ml_students_age)
print(py_students_age)
</pre></div>

<div class="wp-block-syntaxhighlighter-code "><pre class="brush: plain; title: ; notranslate">
&#x5B;22 20 22 42 40 21 35 23 22 24 24 21 44 25 24 40 41 44 44 44 19 23 33 27
 29 21 28 18 34 31 32 29 32 18 39 23 26 24 33 21 20 26 38 25 38 31 30 20
 39 32 41 20 24 27 26 22 33 31 22 38 37 33 34 28 28 34 34 34 33 40 34 23
 33 39 39 25 42 27 23 28 33 31 44 39 28 26 25 29 23 39 39 38 41 34 26 38
 35 42 31 29]
&#x5B;21 29 26 22 21 20 29 29 26 38 28 32 35 20 21 16 39 26 39 31 27 23 29 37
 32 30 21 36 18 32 17 20 18 28 17 30 29 26 35 31 19 19 19 39 21 26 27 17
 23 22 37 21 35 37 16 33 36 39 31 33 37 26 26 17 17 17 23 27 28 32 38 20
 19 33 24 36 34 27 25 21 33 15 39 15 37 27 32 35 21 37 16 38 36 18 39 21
 29 27 18 30]
</pre></div>


<h4>Plotting Histogram Using Matplotlib</h4>
<p>Plotting histogram of machine learning students age.</p>


<div class="wp-block-syntaxhighlighter-code "><pre class="brush: python; title: ; notranslate">
plt.hist(ml_students_age)

plt.title(&quot;ML Students age histograms&quot;)
plt.xlabel(&quot;Students age cotegory&quot;)
plt.ylabel(&quot;No. Students age&quot;)
plt.show()
</pre></div>


<p>Output &gt;&gt;&gt;</p>
<figure id="attachment_555" aria-describedby="caption-attachment-555" style="width: 679px" class="wp-caption aligncenter"><img loading="lazy" decoding="async" class="wp-image-555 size-full" src="https://i0.wp.com/indianaiproduction.com/wp-content/uploads/2019/06/Matplotlib-Histogram-of-ML-students-age.png?resize=679%2C466&#038;ssl=1" alt="Matplotlib Histogram of ML students age" width="679" height="466" srcset="https://i0.wp.com/indianaiproduction.com/wp-content/uploads/2019/06/Matplotlib-Histogram-of-ML-students-age.png?w=679&amp;ssl=1 679w, https://i0.wp.com/indianaiproduction.com/wp-content/uploads/2019/06/Matplotlib-Histogram-of-ML-students-age.png?resize=300%2C206&amp;ssl=1 300w" sizes="(max-width: 679px) 100vw, 679px" data-recalc-dims="1" /><figcaption id="caption-attachment-555" class="wp-caption-text">Fig 1.1 &#8211; Matplotlib Histogram of ML students age</figcaption></figure>



<h4>Plotting Histogram Using Matplotlib with parameters</h4>


<div class="wp-block-syntaxhighlighter-code "><pre class="brush: python; title: ; notranslate">
bins = &#x5B;15,20,25,30,35,40,45] # category of ML students age on x axis
plt.figure(figsize = (16,9)) # size of histogram in 16:9 format


plt.hist(ml_students_age, bins, rwidth=0.8, histtype = &quot;bar&quot;,
         orientation='vertical', color = &quot;m&quot;, label = &quot;ML Student&quot;)

plt.title(&quot;ML Students age histograms&quot;)
plt.xlabel(&quot;Students age cotegory&quot;)
plt.ylabel(&quot;No. Students age&quot;)
plt.legend()
plt.show()
</pre></div>


<p>Output &gt;&gt;&gt;</p>
<figure id="attachment_556" aria-describedby="caption-attachment-556" style="width: 995px" class="wp-caption aligncenter"><img loading="lazy" decoding="async" class="size-full wp-image-556" src="https://i0.wp.com/indianaiproduction.com/wp-content/uploads/2019/06/Matplotlib-Histogram-of-ML-students-age-with-parameters.png?resize=995%2C578&#038;ssl=1" alt="Matplotlib Histogram of ML students age with parameters" width="995" height="578" srcset="https://i0.wp.com/indianaiproduction.com/wp-content/uploads/2019/06/Matplotlib-Histogram-of-ML-students-age-with-parameters.png?w=995&amp;ssl=1 995w, https://i0.wp.com/indianaiproduction.com/wp-content/uploads/2019/06/Matplotlib-Histogram-of-ML-students-age-with-parameters.png?resize=300%2C174&amp;ssl=1 300w, https://i0.wp.com/indianaiproduction.com/wp-content/uploads/2019/06/Matplotlib-Histogram-of-ML-students-age-with-parameters.png?resize=768%2C446&amp;ssl=1 768w" sizes="(max-width: 995px) 100vw, 995px" data-recalc-dims="1" /><figcaption id="caption-attachment-556" class="wp-caption-text">Fig 1.2 &#8211; Matplotlib Histogram of ML students age with parameters</figcaption></figure>



<h4>Plotting two Histogram Using Matplotlib with parameters</h4>


<div class="wp-block-syntaxhighlighter-code "><pre class="brush: python; title: ; notranslate">
from matplotlib import style # for style 
style.use(&quot;ggplot&quot;) # return grid
plt.figure(figsize = (16,9)) 

plt.hist(&#x5B;ml_students_age, py_students_age], bins, rwidth=0.8, histtype = &quot;bar&quot;,
         orientation='vertical', color = &#x5B;&quot;m&quot;, &quot;y&quot;], label = &#x5B;&quot;ML Student&quot;, &quot;Py Student&quot;])

#plt.hist(py_students_age, bins, rwidth=0.8, histtype = &quot;bar&quot;,
#         orientation='vertical', color = &quot;y&quot;, label = &quot;Py Student&quot;)

plt.title(&quot;ML &amp; Py Students age histograms&quot;)
plt.xlabel(&quot;Students age cotegory&quot;)
plt.ylabel(&quot;No. Students age&quot;)
plt.legend()
plt.show()
</pre></div>


<p>Output &gt;&gt;&gt;</p>
<figure id="attachment_557" aria-describedby="caption-attachment-557" style="width: 1007px" class="wp-caption aligncenter"><img loading="lazy" decoding="async" class="size-full wp-image-557" src="https://i0.wp.com/indianaiproduction.com/wp-content/uploads/2019/06/Matplotlib-Histogram-of-ML-Py-students-age-with-parameters.png?resize=1007%2C578&#038;ssl=1" alt="Matplotlib Histogram of ML &amp; Py students age with parameters" width="1007" height="578" srcset="https://i0.wp.com/indianaiproduction.com/wp-content/uploads/2019/06/Matplotlib-Histogram-of-ML-Py-students-age-with-parameters.png?w=1007&amp;ssl=1 1007w, https://i0.wp.com/indianaiproduction.com/wp-content/uploads/2019/06/Matplotlib-Histogram-of-ML-Py-students-age-with-parameters.png?resize=300%2C172&amp;ssl=1 300w, https://i0.wp.com/indianaiproduction.com/wp-content/uploads/2019/06/Matplotlib-Histogram-of-ML-Py-students-age-with-parameters.png?resize=768%2C441&amp;ssl=1 768w" sizes="(max-width: 1007px) 100vw, 1007px" data-recalc-dims="1" /><figcaption id="caption-attachment-557" class="wp-caption-text">Fig 1.3 &#8211; Matplotlib Histogram of ML &amp; Py students age with parameters</figcaption></figure>



<h3>Conclusion</h3>
<p>In <strong>matplotlib histogram blog</strong>, we learn how to plot one and multiple histograms with a real-time example using plt.hist() method. Along with that used different method with different parameter. We suggest you make your hand dirty with each and every parameter of the above methods. This is the best coding practice. After completion of the <a href="https://indianaiproduction.com/python-matplotlib-tutorial/" target="_blank" rel="noopener noreferrer">matplotlib tutorial</a> jump on Seaborn.</p>



<p>Download Jupyter file matplotlib line plot source code</p>


<div class="su-button-center"><a href="https://drive.google.com/file/d/1Yt0a81p8wi1d0C4BnR-KicO0IJrhAKsZ/view?usp=sharing" class="su-button su-button-style-3d" style="color:#FFFFFF;background-color:#38bb04;border-color:#2d9604;border-radius:24px" target="_self"><span style="color:#FFFFFF;padding:5px 14px;font-size:12px;line-height:18px;border-color:#74d050;border-radius:24px;text-shadow:none"><i class="sui sui-cloud-download" style="font-size:12px;color:#FFFFFF"></i> Matplotlib Histogram source code</span></a></div>



<p>Visite to the official site of <a href="http://www.matplotlib.org">matplotlib.org</a></p>
<p>The post <a rel="nofollow" href="https://indianaiproduction.com/matplotlib-histogram/">Matplotlib Histogram &#8211; Python Matplotlib Tutorial</a> appeared first on <a rel="nofollow" href="https://indianaiproduction.com">Indian AI Production</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://indianaiproduction.com/matplotlib-histogram/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
		<post-id xmlns="com-wordpress:feed-additions:1">551</post-id>	</item>
		<item>
		<title>Matplotlib Line Plot &#8211; Python Matplotlib Tutorial</title>
		<link>https://indianaiproduction.com/matplotlib-line-plot/</link>
					<comments>https://indianaiproduction.com/matplotlib-line-plot/#respond</comments>
		
		<dc:creator><![CDATA[Indian AI Production]]></dc:creator>
		<pubDate>Sun, 23 Jun 2019 13:22:45 +0000</pubDate>
				<category><![CDATA[Python Matplotlib Tutorial]]></category>
		<category><![CDATA[line plot]]></category>
		<category><![CDATA[matplotlib line plot]]></category>
		<category><![CDATA[matplotlib multiple line]]></category>
		<category><![CDATA[Matplotlib Tutorial]]></category>
		<guid isPermaLink="false">https://indianaiproduction.com/?p=450</guid>

					<description><![CDATA[<p>Matplotlib Line Plot In this blog, you will learn how to draw a matplotlib line plot with different style and format. The pyplot.plot() or plt.plot() is a method of matplotlib pyplot module use to plot the line. Syntax: plt.plot(*args, scalex=True, scaley=True, data=None, **kwargs) Import pyplot module from matplotlib python library using import keyword and give &#8230;</p>
<p class="read-more"> <a class="" href="https://indianaiproduction.com/matplotlib-line-plot/"> <span class="screen-reader-text">Matplotlib Line Plot &#8211; Python Matplotlib Tutorial</span> Read More &#187;</a></p>
<p>The post <a rel="nofollow" href="https://indianaiproduction.com/matplotlib-line-plot/">Matplotlib Line Plot &#8211; Python Matplotlib Tutorial</a> appeared first on <a rel="nofollow" href="https://indianaiproduction.com">Indian AI Production</a>.</p>
]]></description>
										<content:encoded><![CDATA[
<h2 class="wp-block-heading">Matplotlib Line Plot</h2>



<p>In this blog, you will learn how to draw a <strong>matplotlib line plot </strong>with different style and format.</p>
<p>The <strong>pyplot.plot() </strong>or<strong> plt.plot()</strong> is a method of matplotlib pyplot module use to plot the line.</p>
<p><strong><span style="color: #ff0000;">Syntax:</span> <span style="color: #800000;">plt<span class="ansi-yellow-intense-fg ansi-bold">.</span>plot<span class="ansi-yellow-intense-fg ansi-bold">(</span><span style="color: #008000;"><span class="ansi-yellow-intense-fg ansi-bold">*</span>args<span class="ansi-yellow-intense-fg ansi-bold">,</span> scalex<span class="ansi-yellow-intense-fg ansi-bold">=</span><span class="ansi-green-intense-fg ansi-bold">True</span><span class="ansi-yellow-intense-fg ansi-bold">,</span> scaley<span class="ansi-yellow-intense-fg ansi-bold">=</span><span class="ansi-green-intense-fg ansi-bold">True</span><span class="ansi-yellow-intense-fg ansi-bold">,</span> data<span class="ansi-yellow-intense-fg ansi-bold">=</span><span class="ansi-green-intense-fg ansi-bold">None</span><span class="ansi-yellow-intense-fg ansi-bold">,</span> <span class="ansi-yellow-intense-fg ansi-bold">**</span>kwargs</span><span class="ansi-yellow-intense-fg ansi-bold">)</span></span></strong></p>
<p>Import pyplot module from matplotlib python library using <strong>import</strong> keyword and give short name plt using <strong>as</strong>  keyword.</p>


<div class="wp-block-syntaxhighlighter-code "><pre class="brush: python; title: ; notranslate">
import matplotlib.pyplot as plt 
</pre></div>


<p>Import Dataset of 15 days Delhi temperature record. The dataset in the form of list data type, you can use <a href="https://indianaiproduction.com/python-numpy-array/" target="_blank" rel="noopener noreferrer">NumPy array</a>, tuple, etc.</p>


<div class="wp-block-syntaxhighlighter-code "><pre class="brush: python; title: ; notranslate">
days = &#x5B;1,2,3,4,5,6,7,8,9,10,11,12,13,14,15]
temperature = &#x5B;36.6, 37, 37.7,39,40.1,43,43.4,45,45.6,40.1,44,45,46.8,47,47.8]

</pre></div>


<p>Plot the line using plt.plot() method and show it using plt.show() method. Here, give a parameter <strong>x</strong> as a days and <strong>y</strong> as a temperature to <strong>plt.plot()&nbsp;</strong></p>


<div class="wp-block-syntaxhighlighter-code "><pre class="brush: python; title: ; notranslate">
plt.plot(days, temperature)
plt.show()
</pre></div>


<p>Output &gt;&gt;&gt;</p>
<figure id="attachment_459" aria-describedby="caption-attachment-459" style="width: 458px" class="wp-caption aligncenter"><img loading="lazy" decoding="async" class="size-full wp-image-459" src="https://i0.wp.com/indianaiproduction.com/wp-content/uploads/2019/06/Matplotlib-line-plot-15-days-Delhi-Temperature-graph.png?resize=458%2C314&#038;ssl=1" alt="Matplotlib line plot - 15 days Delhi Temperature graph" width="458" height="314" srcset="https://i0.wp.com/indianaiproduction.com/wp-content/uploads/2019/06/Matplotlib-line-plot-15-days-Delhi-Temperature-graph.png?w=458&amp;ssl=1 458w, https://i0.wp.com/indianaiproduction.com/wp-content/uploads/2019/06/Matplotlib-line-plot-15-days-Delhi-Temperature-graph.png?resize=300%2C206&amp;ssl=1 300w" sizes="(max-width: 458px) 100vw, 458px" data-recalc-dims="1" /><figcaption id="caption-attachment-459" class="wp-caption-text">Fig 1.1 &#8211; 15 days temperature record of Delhi city</figcaption></figure>



<p>Fig 1.1 not showing any useful information, because it has no x-axis,&nbsp; y-axis, and title. So for this, you can use the below methods.</p>
<p><strong><span style="color: #ff0000;">Syntax:</span> <span style="color: #800000;">plt<span class="ansi-yellow-intense-fg ansi-bold">.</span>xlabel<span class="ansi-yellow-intense-fg ansi-bold">(</span><span style="color: #008000;">xlabel<span class="ansi-yellow-intense-fg ansi-bold">,</span> fontdict<span class="ansi-yellow-intense-fg ansi-bold">=</span><span class="ansi-green-intense-fg ansi-bold">None</span><span class="ansi-yellow-intense-fg ansi-bold">,</span> labelpad<span class="ansi-yellow-intense-fg ansi-bold">=</span><span class="ansi-green-intense-fg ansi-bold">None</span><span class="ansi-yellow-intense-fg ansi-bold">,</span> <span class="ansi-yellow-intense-fg ansi-bold">**</span>kwargs</span><span class="ansi-yellow-intense-fg ansi-bold">)</span></span></strong></p>
<p><strong><span style="color: #ff0000;">Syntax:</span> <span style="color: #800000;">plt<span class="ansi-yellow-intense-fg ansi-bold">.</span>ylabel<span class="ansi-yellow-intense-fg ansi-bold">(</span><span style="color: #008000;">ylabel<span class="ansi-yellow-intense-fg ansi-bold">,</span> fontdict<span class="ansi-yellow-intense-fg ansi-bold">=</span><span class="ansi-green-intense-fg ansi-bold">None</span><span class="ansi-yellow-intense-fg ansi-bold">,</span> labelpad<span class="ansi-yellow-intense-fg ansi-bold">=</span><span class="ansi-green-intense-fg ansi-bold">None</span><span class="ansi-yellow-intense-fg ansi-bold">,</span> <span class="ansi-yellow-intense-fg ansi-bold">**</span>kwargs</span><span class="ansi-yellow-intense-fg ansi-bold">)</span> </span></strong></p>
<p><strong><span style="color: #ff0000;">Syntax:</span> <span style="color: #800000;">plt<span class="ansi-yellow-intense-fg ansi-bold">.</span>title<span class="ansi-yellow-intense-fg ansi-bold">(</span><span style="color: #008000;">label<span class="ansi-yellow-intense-fg ansi-bold">,</span> fontdict<span class="ansi-yellow-intense-fg ansi-bold">=</span><span class="ansi-green-intense-fg ansi-bold">None</span><span class="ansi-yellow-intense-fg ansi-bold">,</span> loc<span class="ansi-yellow-intense-fg ansi-bold">=</span><span class="ansi-blue-intense-fg ansi-bold">&#8216;center&#8217;</span><span class="ansi-yellow-intense-fg ansi-bold">,</span> pad<span class="ansi-yellow-intense-fg ansi-bold">=</span><span class="ansi-green-intense-fg ansi-bold">None</span><span class="ansi-yellow-intense-fg ansi-bold">,</span> <span class="ansi-yellow-intense-fg ansi-bold">**</span>kwargs</span><span class="ansi-yellow-intense-fg ansi-bold">)</span> </span></strong></p>


<div class="wp-block-syntaxhighlighter-code "><pre class="brush: python; title: ; notranslate">
# plot line with x-axis, y-axis and title
plt.plot(days, temperature)
plt.title(&quot;Delhi Temperature&quot;)
plt.xlabel(&quot;days&quot;)
plt.ylabel(&quot;temperature&quot;)
plt.show()
</pre></div>


<p>Output &gt;&gt;&gt;</p>
<figure id="attachment_461" aria-describedby="caption-attachment-461" style="width: 448px" class="wp-caption aligncenter"><img loading="lazy" decoding="async" class="size-full wp-image-461" src="https://i0.wp.com/indianaiproduction.com/wp-content/uploads/2019/06/Matplotlib-line-plot-15-days-Delhi-Temperature-graph-with-info.png?resize=448%2C315&#038;ssl=1" alt="Matplotlib line plot - 15 days Delhi Temperature graph with information" width="448" height="315" srcset="https://i0.wp.com/indianaiproduction.com/wp-content/uploads/2019/06/Matplotlib-line-plot-15-days-Delhi-Temperature-graph-with-info.png?w=448&amp;ssl=1 448w, https://i0.wp.com/indianaiproduction.com/wp-content/uploads/2019/06/Matplotlib-line-plot-15-days-Delhi-Temperature-graph-with-info.png?resize=300%2C211&amp;ssl=1 300w" sizes="(max-width: 448px) 100vw, 448px" data-recalc-dims="1" /><figcaption id="caption-attachment-461" class="wp-caption-text">Fig 1.2 – 15 days temperature record of Delhi city with information</figcaption></figure>



<p>Observe Fig 1.1 and Fig 1.2, the starting axis value take automatically by plt.plot() method. If you want to set it manually, then use <strong>plt.axis()</strong> method.</p>
<p><strong><span style="color: #ff0000;">Syntax:</span> <span style="color: #800000;">plt<span class="ansi-yellow-intense-fg ansi-bold">.</span>axis<span class="ansi-yellow-intense-fg ansi-bold">(<span style="color: #008000;">xmin, xmax, ymin, ymax</span></span><span class="ansi-yellow-intense-fg ansi-bold">)</span></span></strong></p>


<div class="wp-block-syntaxhighlighter-code "><pre class="brush: python; title: ; notranslate">
plt.plot(days, temperature)
plt.axis(&#x5B;0,30, 0,50]) # set axis 
plt.title(&quot;Delhi Temperature&quot;)
plt.xlabel(&quot;days&quot;)
plt.ylabel(&quot;temperature&quot;)
plt.show()
</pre></div>


<p>Output &gt;&gt;&gt;</p>
<figure id="attachment_463" aria-describedby="caption-attachment-463" style="width: 470px" class="wp-caption aligncenter"><img loading="lazy" decoding="async" class="size-full wp-image-463" src="https://i0.wp.com/indianaiproduction.com/wp-content/uploads/2019/06/Matplotlib-line-plot-15-days-Delhi-Temperature-graph-set-with-axis.png?resize=470%2C314&#038;ssl=1" alt="Matplotlib line plot - 15 days Delhi Temperature graph set with axis" width="470" height="314" srcset="https://i0.wp.com/indianaiproduction.com/wp-content/uploads/2019/06/Matplotlib-line-plot-15-days-Delhi-Temperature-graph-set-with-axis.png?w=470&amp;ssl=1 470w, https://i0.wp.com/indianaiproduction.com/wp-content/uploads/2019/06/Matplotlib-line-plot-15-days-Delhi-Temperature-graph-set-with-axis.png?resize=300%2C200&amp;ssl=1 300w" sizes="(max-width: 470px) 100vw, 470px" data-recalc-dims="1" /><figcaption id="caption-attachment-463" class="wp-caption-text">Fig 1.3 – 15 days temperature record of Delhi city set with the axis</figcaption></figure>



<p>The plt.plot() method has much more parameter. So, let&#8217;s play with some of them.</p>


<div class="wp-block-syntaxhighlighter-code "><pre class="brush: python; title: ; notranslate">
plt.plot(days, temperature, color = &quot;g&quot;, marker = &quot;o&quot;, linestyle= &quot;--&quot;, linewidth = 3,
        markersize = 10)
plt.title(&quot;Delhi Temperature&quot;)
plt.xlabel(&quot;days&quot;)
plt.ylabel(&quot;temperature&quot;)
plt.show()
</pre></div>


<p>Output &gt;&gt;&gt;</p>
<figure id="attachment_465" aria-describedby="caption-attachment-465" style="width: 458px" class="wp-caption aligncenter"><img loading="lazy" decoding="async" class="size-full wp-image-465" src="https://i0.wp.com/indianaiproduction.com/wp-content/uploads/2019/06/Matplotlib-line-plot-15-days-Delhi-Temperature-graph-set-with-axis-1.png?resize=458%2C314&#038;ssl=1" alt="Matplotlib line plot - 15 days Delhi Temperature graph set with axis" width="458" height="314" srcset="https://i0.wp.com/indianaiproduction.com/wp-content/uploads/2019/06/Matplotlib-line-plot-15-days-Delhi-Temperature-graph-set-with-axis-1.png?w=458&amp;ssl=1 458w, https://i0.wp.com/indianaiproduction.com/wp-content/uploads/2019/06/Matplotlib-line-plot-15-days-Delhi-Temperature-graph-set-with-axis-1.png?resize=300%2C206&amp;ssl=1 300w" sizes="(max-width: 458px) 100vw, 458px" data-recalc-dims="1" /><figcaption id="caption-attachment-465" class="wp-caption-text">Fig 1.4 – 15 days temperature record of Delhi city with parameters</figcaption></figure>
<p><span style="font-size: 14pt;"><strong>Color Parameter Values</strong></span></p>
<table style="height: 189px; width: 100%; border-collapse: collapse; border-style: solid;">
<tbody>
<tr style="height: 21px;">
<td style="width: 50%; height: 21px;"><span style="color: #000000;"><strong>Character</strong></span></td>
<td style="width: 50%; height: 21px;"><span style="color: #000000;"><strong>Color</strong></span></td>
</tr>
<tr style="height: 21px;">
<td style="width: 50%; height: 21px; text-align: left;"><strong><span style="color: #ff6600;">b</span></strong></td>
<td style="width: 50%; height: 21px; text-align: left;"><strong><span style="color: #ff6600;">blue</span></strong></td>
</tr>
<tr style="height: 21px;">
<td style="width: 50%; height: 21px; text-align: left;"><strong><span style="color: #ff6600;">g</span></strong></td>
<td style="width: 50%; height: 21px; text-align: left;"><strong><span style="color: #ff6600;">green</span></strong></td>
</tr>
<tr style="height: 21px;">
<td style="width: 50%; height: 21px; text-align: left;"><strong><span style="color: #ff6600;">r</span></strong></td>
<td style="width: 50%; height: 21px; text-align: left;"><strong><span style="color: #ff6600;">red</span></strong></td>
</tr>
<tr style="height: 21px;">
<td style="width: 50%; height: 21px; text-align: left;"><strong><span style="color: #ff6600;">c</span></strong></td>
<td style="width: 50%; height: 21px; text-align: left;"><strong><span style="color: #ff6600;">cyan</span></strong></td>
</tr>
<tr style="height: 21px;">
<td style="width: 50%; height: 21px; text-align: left;"><strong><span style="color: #ff6600;">m</span></strong></td>
<td style="width: 50%; height: 21px; text-align: left;"><strong><span style="color: #ff6600;">magenta</span></strong></td>
</tr>
<tr style="height: 21px;">
<td style="width: 50%; height: 21px; text-align: left;"><strong><span style="color: #ff6600;">y</span></strong></td>
<td style="width: 50%; height: 21px; text-align: left;"><strong><span style="color: #ff6600;">yellow</span></strong></td>
</tr>
<tr style="height: 21px;">
<td style="width: 50%; height: 21px; text-align: left;"><strong><span style="color: #ff6600;">k</span></strong></td>
<td style="width: 50%; height: 21px; text-align: left;"><strong><span style="color: #ff6600;">black</span></strong></td>
</tr>
<tr style="height: 21px;">
<td style="width: 50%; height: 21px;"><strong><span style="color: #ff6600;">w</span></strong></td>
<td style="width: 50%; height: 21px;"><strong><span style="color: #ff6600;">white</span></strong></td>
</tr>
</tbody>
</table>



<p><span class="tadv-format-panel" style="font-size: 14pt;"><strong>Marker Parameter Values</strong></span></p>
<table style="border-collapse: collapse; width: 100%; height: 478px;">
<tbody>
<tr style="height: 21px;">
<td style="width: 50%; height: 21px;"><span style="color: #000000;"><strong>Character</strong></span></td>
<td style="width: 50%; height: 21px;"><span style="color: #000000;"><strong>Description</strong></span></td>
</tr>
<tr style="height: 21px;">
<td style="width: 50%; height: 21px;"><span style="color: #ff6600;"><strong>.</strong></span></td>
<td style="width: 50%; height: 21px;"><span style="color: #ff6600;"><strong>point marker</strong></span></td>
</tr>
<tr style="height: 21px;">
<td style="width: 50%; height: 21px;"><span style="color: #ff6600;"><strong>,</strong></span></td>
<td style="width: 50%; height: 21px;"><span style="color: #ff6600;"><strong>pixel marker</strong></span></td>
</tr>
<tr style="height: 21px;">
<td style="width: 50%; height: 27px;"><span style="color: #ff6600;"><strong>o</strong></span></td>
<td style="width: 50%; height: 27px;"><span style="color: #ff6600;"><strong>circle marker</strong></span></td>
</tr>
<tr style="height: 21px;">
<td style="width: 50%; height: 21px;"><span style="color: #ff6600;"><strong>v</strong></span></td>
<td style="width: 50%; height: 21px;"><span style="color: #ff6600;"><strong>triangle_down marker</strong></span></td>
</tr>
<tr style="height: 21px;">
<td style="width: 50%; height: 21px;"><span style="color: #ff6600;"><strong>^</strong></span></td>
<td style="width: 50%; height: 21px;"><span style="color: #ff6600;"><strong>triangle_up marker</strong></span></td>
</tr>
<tr style="height: 21px;">
<td style="width: 50%; height: 21px;"><span style="color: #ff6600;"><strong>&lt;</strong></span></td>
<td style="width: 50%; height: 21px;"><span style="color: #ff6600;"><strong>triangle_left marker</strong></span></td>
</tr>
<tr style="height: 21px;">
<td style="width: 50%; height: 10px;"><span style="color: #ff6600;"><strong>&gt;</strong></span></td>
<td style="width: 50%; height: 10px;"><span style="color: #ff6600;"><strong>triangle_right marker</strong></span></td>
</tr>
<tr style="height: 21px;">
<td style="width: 50%; height: 21px;"><span style="color: #ff6600;"><strong>1</strong></span></td>
<td style="width: 50%; height: 21px;"><span style="color: #ff6600;"><strong>tri_down marker</strong></span></td>
</tr>
<tr style="height: 21px;">
<td style="width: 50%; height: 21px;"><span style="color: #ff6600;"><strong>2</strong></span></td>
<td style="width: 50%; height: 21px;"><span style="color: #ff6600;"><strong>tri_up marker</strong></span></td>
</tr>
<tr style="height: 21px;">
<td style="width: 50%; height: 21px;"><span style="color: #ff6600;"><strong>3</strong></span></td>
<td style="width: 50%; height: 21px;"><span style="color: #ff6600;"><strong>tri_left marker</strong></span></td>
</tr>
<tr style="height: 21px;">
<td style="width: 50%; height: 21px;"><span style="color: #ff6600;"><strong>4</strong></span></td>
<td style="width: 50%; height: 21px;"><span style="color: #ff6600;"><strong>tri_right marker</strong></span></td>
</tr>
<tr style="height: 21px;">
<td style="width: 50%; height: 21px;"><span style="color: #ff6600;"><strong>s</strong></span></td>
<td style="width: 50%; height: 21px;"><span style="color: #ff6600;"><strong>square marker</strong></span></td>
</tr>
<tr style="height: 21px;">
<td style="width: 50%; height: 21px;"><span style="color: #ff6600;"><strong>p</strong></span></td>
<td style="width: 50%; height: 21px;"><span style="color: #ff6600;"><strong>pentagon marker</strong></span></td>
</tr>
<tr style="height: 21px;">
<td style="width: 50%; height: 21px;"><span style="color: #ff6600;"><strong>*</strong></span></td>
<td style="width: 50%; height: 21px;"><span style="color: #ff6600;"><strong>star marker</strong></span></td>
</tr>
<tr style="height: 21px;">
<td style="width: 50%; height: 21px;"><span style="color: #ff6600;"><strong>h</strong></span></td>
<td style="width: 50%; height: 21px;"><span style="color: #ff6600;"><strong>hexagon1 marker</strong></span></td>
</tr>
<tr style="height: 21px;">
<td style="width: 50%; height: 21px;"><span style="color: #ff6600;"><strong>H</strong></span></td>
<td style="width: 50%; height: 21px;"><span style="color: #ff6600;"><strong>hexagon2 marker</strong></span></td>
</tr>
<tr style="height: 21px;">
<td style="width: 50%; height: 21px;"><span style="color: #ff6600;"><strong>+</strong></span></td>
<td style="width: 50%; height: 21px;"><span style="color: #ff6600;"><strong>plus marker</strong></span></td>
</tr>
<tr style="height: 21px;">
<td style="width: 50%; height: 21px;"><span style="color: #ff6600;"><strong>x</strong></span></td>
<td style="width: 50%; height: 21px;"><span style="color: #ff6600;"><strong>x marker</strong></span></td>
</tr>
<tr style="height: 21px;">
<td style="width: 50%; height: 21px;"><span style="color: #ff6600;"><strong>D</strong></span></td>
<td style="width: 50%; height: 21px;"><span style="color: #ff6600;"><strong>diamond marker</strong></span></td>
</tr>
<tr style="height: 21px;">
<td style="width: 50%; height: 21px;"><span style="color: #ff6600;"><strong>d</strong></span></td>
<td style="width: 50%; height: 21px;"><span style="color: #ff6600;"><strong>thin_diamond marker</strong></span></td>
</tr>
<tr style="height: 21px;">
<td style="width: 50%; height: 21px;"><span style="color: #ff6600;"><strong>|</strong></span></td>
<td style="width: 50%; height: 21px;"><span style="color: #ff6600;"><strong>vline marker</strong></span></td>
</tr>
<tr style="height: 21px;">
<td style="width: 50%; height: 21px;"><span style="color: #ff6600;"><strong>_</strong></span></td>
<td style="width: 50%; height: 21px;"><span style="color: #ff6600;"><strong>hline marker</strong></span></td>
</tr>
</tbody>
</table>



<p><span style="font-size: 14pt;"><strong>Line Style parameters values</strong></span></p>
<table style="border-collapse: collapse; width: 100%; height: 105px;">
<tbody>
<tr style="height: 21px;">
<td style="width: 50%; height: 21px;"><strong><span style="color: #000000;">Character</span> </strong></td>
<td style="width: 50%; height: 21px;"><strong><span style="color: #000000;">Description</span> </strong></td>
</tr>
<tr style="height: 21px;">
<td style="width: 50%; height: 21px;"><strong><span style="color: #ff6600;">_</span></strong></td>
<td style="width: 50%; height: 21px;"><strong><span style="color: #ff6600;">solid line style</span></strong></td>
</tr>
<tr style="height: 21px;">
<td style="width: 50%; height: 21px;"><strong><span style="color: #ff6600;">&#8212;</span></strong></td>
<td style="width: 50%; height: 21px;"><strong><span style="color: #ff6600;">dashed line style</span></strong></td>
</tr>
<tr style="height: 21px;">
<td style="width: 50%; height: 21px;"><strong><span style="color: #ff6600;">_.</span></strong></td>
<td style="width: 50%; height: 21px;"><strong><span style="color: #ff6600;">dash-dot line style</span></strong></td>
</tr>
<tr style="height: 21px;">
<td style="width: 50%; height: 21px;"><strong><span style="color: #ff6600;">:</span></strong></td>
<td style="width: 50%; height: 21px;"><strong><span style="color: #ff6600;">dotted line style</span></strong></td>
</tr>
</tbody>
</table>



<p>So, try to use different values of the above parameters. Then you will get a different output.</p>
<p>If you want to change the bar chart&#8217;s background color and add grid then use <strong>style.use()</strong> method. For this first, need to import the style module from matplotlib. </p>
<p><span style="color: #800000;"><strong><span style="color: #ff0000;">Syntax:</span> style<span class="ansi-yellow-intense-fg ansi-bold">.</span>use<span class="ansi-yellow-intense-fg ansi-bold">(</span><span style="color: #008000;">style</span><span class="ansi-yellow-intense-fg ansi-bold">)</span></strong></span></p>
<p>To add a legend in the graph to describe more information about it, use plt.legend().</p>
<p><strong><span style="color: #800000;"><span style="color: #ff0000;">Syntax: </span>plt<span class="ansi-yellow-intense-fg ansi-bold">.</span>legend<span class="ansi-yellow-intense-fg ansi-bold">(</span><span style="color: #008000;"><span class="ansi-yellow-intense-fg ansi-bold">*</span>args<span class="ansi-yellow-intense-fg ansi-bold">,</span> <span class="ansi-yellow-intense-fg ansi-bold">**</span>kwargs</span><span class="ansi-yellow-intense-fg ansi-bold">)</span></span></strong></p>


<div class="wp-block-syntaxhighlighter-code "><pre class="brush: python; title: ; notranslate">
from matplotlib import style # import style module
style.use(&quot;ggplot&quot;) # give ggplot parameter value to use() method
plt.plot(days, temperature, &quot;mo--&quot;, linewidth = 3,
        markersize = 10, label = &quot;Temp line&quot;)
plt.title(&quot;Delhi Temperature&quot;, fontsize=15)
plt.xlabel(&quot;days&quot;,fontsize=13)
plt.ylabel(&quot;temperature&quot;,fontsize=13)
plt.legend(loc = 4) 
plt.show()
</pre></div>


<p>Output &gt;&gt;&gt;</p>
<figure id="attachment_511" aria-describedby="caption-attachment-511" style="width: 474px" class="wp-caption aligncenter"><img loading="lazy" decoding="async" class="size-full wp-image-511" src="https://i0.wp.com/indianaiproduction.com/wp-content/uploads/2019/06/Matplotlib-line-plot-15-days-Delhi-Temperature-graph-with-style-and-legend.png?resize=474%2C343&#038;ssl=1" alt="Matplotlib line plot - 15 days Delhi Temperature graph with style and legend" width="474" height="343" srcset="https://i0.wp.com/indianaiproduction.com/wp-content/uploads/2019/06/Matplotlib-line-plot-15-days-Delhi-Temperature-graph-with-style-and-legend.png?w=474&amp;ssl=1 474w, https://i0.wp.com/indianaiproduction.com/wp-content/uploads/2019/06/Matplotlib-line-plot-15-days-Delhi-Temperature-graph-with-style-and-legend.png?resize=300%2C217&amp;ssl=1 300w" sizes="(max-width: 474px) 100vw, 474px" data-recalc-dims="1" /><figcaption id="caption-attachment-511" class="wp-caption-text">Fig 1.5 – 15 days temperature record of Delhi city with style and legend</figcaption></figure>



<h3>Matplotlib Multiple Lines Plot</h3>
<p>To plot multiple lines using a matplotlib line plot method use more plt.plot() method similar to your dataset.</p>
<p>Here, we have 15 days temperature record of Delhi and Mumbai city</p>


<div class="wp-block-syntaxhighlighter-code "><pre class="brush: python; title: ; notranslate">
days = &#x5B;1,2,3,4,5,6,7,8,9,10,11,12,13,14,15]
delhi_tem = &#x5B;36.6, 37, 37.7,39,40.1,43,43.4,45,45.6,40.1,44,45,46.8,47,47.8]
mumbai_tem = &#x5B;39,39.4,40,40.7,41,42.5,43.5,44,44.9,44,45,45.1,46,47,46]

plt.plot(days, delhi_tem, &quot;mo--&quot;, linewidth = 3,
        markersize = 10, label = &quot;Delhi tem&quot;)

plt.plot(days, mumbai_tem, &quot;yo:&quot;, linewidth = 3,
        markersize = 10, label = &quot;Mumbai tem}&quot;)

plt.title(&quot;Delhi  &amp; Mumbai Temperature&quot;, fontsize=15)
plt.xlabel(&quot;days&quot;,fontsize=13)
plt.ylabel(&quot;temperature&quot;,fontsize=13)
plt.legend(loc = 4)
plt.show()

</pre></div>


<p>Output &gt;&gt;&gt;</p>
<figure id="attachment_512" aria-describedby="caption-attachment-512" style="width: 649px" class="wp-caption aligncenter"><img loading="lazy" decoding="async" class="size-full wp-image-512" src="https://i0.wp.com/indianaiproduction.com/wp-content/uploads/2019/06/Matplotlib-line-plot-15-days-Delhi-Mumbai-city-Temperature-graph.png?resize=649%2C466&#038;ssl=1" alt="Matplotlib line plot - 15 days Delhi &amp; Mumbai city Temperature graph" width="649" height="466" srcset="https://i0.wp.com/indianaiproduction.com/wp-content/uploads/2019/06/Matplotlib-line-plot-15-days-Delhi-Mumbai-city-Temperature-graph.png?w=649&amp;ssl=1 649w, https://i0.wp.com/indianaiproduction.com/wp-content/uploads/2019/06/Matplotlib-line-plot-15-days-Delhi-Mumbai-city-Temperature-graph.png?resize=300%2C215&amp;ssl=1 300w" sizes="(max-width: 649px) 100vw, 649px" data-recalc-dims="1" /><figcaption id="caption-attachment-512" class="wp-caption-text">Fig 1.6 – 15 days temperature record of Delhi &amp; Mumbai city</figcaption></figure>



<p>If you want to change or add grid then use <strong>plt.grid()</strong> method.</p>
<p><strong><span style="color: #800000;"><span style="color: #ff0000;">Syntax:</span> plt<span class="ansi-yellow-intense-fg ansi-bold">.</span>grid<span class="ansi-yellow-intense-fg ansi-bold">(</span><span style="color: #008000;">b<span class="ansi-yellow-intense-fg ansi-bold">=</span><span class="ansi-green-intense-fg ansi-bold">None</span><span class="ansi-yellow-intense-fg ansi-bold">,</span> which<span class="ansi-yellow-intense-fg ansi-bold">=</span><span class="ansi-blue-intense-fg ansi-bold">&#8216;major&#8217;</span><span class="ansi-yellow-intense-fg ansi-bold">,</span> axis<span class="ansi-yellow-intense-fg ansi-bold">=</span><span class="ansi-blue-intense-fg ansi-bold">&#8216;both&#8217;</span><span class="ansi-yellow-intense-fg ansi-bold">,</span> <span class="ansi-yellow-intense-fg ansi-bold">**</span>kwargs</span><span class="ansi-yellow-intense-fg ansi-bold">)</span></span></strong></p>


<div class="wp-block-syntaxhighlighter-code "><pre class="brush: python; title: ; notranslate">
plt.plot(days, delhi_tem, &quot;mo-&quot;, linewidth = 3,
        markersize = 10, label = &quot;Delhi tem&quot;)

plt.plot(days, mumbai_tem, &quot;k-&quot;, linewidth = 5,
        markersize = 10, label = &quot;Mumbai tem&quot;)

plt.title(&quot;Delhi  &amp; Mumbai Temperature&quot;, fontsize=15)
plt.xlabel(&quot;days&quot;,fontsize=13)
plt.ylabel(&quot;temperature&quot;,fontsize=13)
plt.legend(loc = 4)
plt.grid(color='c', linestyle='-', linewidth=2) # grid with parameter
plt.show()
</pre></div>


<p>Output &gt;&gt;&gt;</p>
<figure id="attachment_514" aria-describedby="caption-attachment-514" style="width: 668px" class="wp-caption aligncenter"><img loading="lazy" decoding="async" class="size-full wp-image-514" src="https://i0.wp.com/indianaiproduction.com/wp-content/uploads/2019/06/Matplotlib-line-plot-15-days-Delhi-Mumbai-city-Temperature-graph-with-grid.png?resize=668%2C466&#038;ssl=1" alt="Matplotlib line plot - 15 days Delhi &amp; Mumbai city Temperature graph with grid" width="668" height="466" srcset="https://i0.wp.com/indianaiproduction.com/wp-content/uploads/2019/06/Matplotlib-line-plot-15-days-Delhi-Mumbai-city-Temperature-graph-with-grid.png?w=668&amp;ssl=1 668w, https://i0.wp.com/indianaiproduction.com/wp-content/uploads/2019/06/Matplotlib-line-plot-15-days-Delhi-Mumbai-city-Temperature-graph-with-grid.png?resize=300%2C209&amp;ssl=1 300w" sizes="(max-width: 668px) 100vw, 668px" data-recalc-dims="1" /><figcaption id="caption-attachment-514" class="wp-caption-text">Fig 1.7 – 15 days temperature record of Delhi &amp; Mumbai city with a grid</figcaption></figure>



<p>In this way, you can plot multiple lines using matplotlib line plot method. </p>
<p><span style="background-color: #00ffff;">N<strong>ote: </strong></span><span style="text-decoration: underline;">When you use style.use(&#8220;ggplot&#8221;). after that, no need to it again because it uses once and applies for all graph.</span></p>



<h3>Conclusion</h3>
<p>In <strong>matplotlib line plot blog</strong>, we learn how to plot one and multiple lines with a real-time example using plt.plot() method. Along with that used different method with different parameter. Suggest you make your hand dirty with each and every parameter of the above methods. This is the best coding practice. After completion of the <a href="https://indianaiproduction.com/python-matplotlib-tutorial/" target="_blank" rel="noopener noreferrer">matplotlib tutorial</a> jump on Seaborn.</p>



<p>Download Jupyter file  matplotlib line plot source code</p>


<div class="su-button-center"><a href="https://drive.google.com/file/d/1mmJByz9ND_xCCGC66ed5HXWOYsqIZTsK/view?usp=sharing" class="su-button su-button-style-3d" style="color:#FFFFFF;background-color:#38bb04;border-color:#2d9604;border-radius:24px" target="_self"><span style="color:#FFFFFF;padding:5px 14px;font-size:12px;line-height:18px;border-color:#74d050;border-radius:24px;text-shadow:none"><i class="sui sui-cloud-download" style="font-size:12px;color:#FFFFFF"></i> Matplotlib line plot source code</span></a></div>



<p>Visite to the official site of <a href="http://www.matplotlib.org">matplotlib.org</a></p>
<p>The post <a rel="nofollow" href="https://indianaiproduction.com/matplotlib-line-plot/">Matplotlib Line Plot &#8211; Python Matplotlib Tutorial</a> appeared first on <a rel="nofollow" href="https://indianaiproduction.com">Indian AI Production</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://indianaiproduction.com/matplotlib-line-plot/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
		<post-id xmlns="com-wordpress:feed-additions:1">450</post-id>	</item>
		<item>
		<title>Python Matplotlib Tutorial &#8211; Mastery in Matplotlib Library</title>
		<link>https://indianaiproduction.com/python-matplotlib-tutorial/</link>
					<comments>https://indianaiproduction.com/python-matplotlib-tutorial/#respond</comments>
		
		<dc:creator><![CDATA[Indian AI Production]]></dc:creator>
		<pubDate>Sat, 22 Jun 2019 10:09:40 +0000</pubDate>
				<category><![CDATA[Python Matplotlib Tutorial]]></category>
		<category><![CDATA[Matplotlib]]></category>
		<category><![CDATA[Matplotlib Python]]></category>
		<category><![CDATA[Matplotlib Tutorial]]></category>
		<category><![CDATA[Python Matplotlib]]></category>
		<guid isPermaLink="false">https://indianaiproduction.com/?p=438</guid>

					<description><![CDATA[<p>Python Matplotlib Tutorial After complication of python NumPy Tutorial and python pandas tutorial. Now, we jump on the python matplotlib tutorial to become a master in it. What is python matplotlib? Matplotlib is a 2D and 3D graph plotting python library. It also supports to create animations and images. This is an advanced part of &#8230;</p>
<p class="read-more"> <a class="" href="https://indianaiproduction.com/python-matplotlib-tutorial/"> <span class="screen-reader-text">Python Matplotlib Tutorial &#8211; Mastery in Matplotlib Library</span> Read More &#187;</a></p>
<p>The post <a rel="nofollow" href="https://indianaiproduction.com/python-matplotlib-tutorial/">Python Matplotlib Tutorial &#8211; Mastery in Matplotlib Library</a> appeared first on <a rel="nofollow" href="https://indianaiproduction.com">Indian AI Production</a>.</p>
]]></description>
										<content:encoded><![CDATA[
<h2>Python Matplotlib Tutorial</h2>



<p>After complication of <a rel="noreferrer noopener" aria-label="python NumPy Tutorial (opens in a new tab)" href="https://indianaiproduction.com/python-numpy-tutorial/" target="_blank">python NumPy Tutorial</a> and python pandas tutorial. Now, we jump on the <strong>python matplotlib tutorial</strong> to become a master in it.</p>



<h3>What is python matplotlib?</h3>
<p>Matplotlib is a 2D and 3D graph plotting python library. It also supports to create animations and images. This is an advanced part of <strong>python matplotlib</strong>. </p>
<p>Using python matplotlib, you can draw a different graph like below:</p>
<ul>
<li><a href="https://indianaiproduction.com/matplotlib-line-plot/" target="_blank" rel="noopener noreferrer"><b>Line plot</b></a></li>
<li><a href="https://indianaiproduction.com/matplotlib-histogram/" target="_blank" rel="noopener noreferrer"><b>Histogram</b></a></li>
<li><a href="https://indianaiproduction.com/matplotlib-bar-chart-python-matplotlib-tutorial/" target="_blank" rel="noopener noreferrer"><b>Bar Chart</b></a></li>
<li><a href="https://indianaiproduction.com/matplotlib-pie-chart" target="_blank" rel="noopener noreferrer"><strong>Pie Chart</strong></a></li>
<li><a href="https://indianaiproduction.com/matplotlib-scatter-plot" target="_blank" rel="noopener noreferrer"><b>Scatterplots</b></a></li>
<li><b>Area Plot</b></li>
<li><b>Error charts</b></li>
<li><b>Power Spectra </b></li>
<li><strong>etc.</strong></li>
</ul>
<p>Other topics:</p>
<ul>
<li><strong><a href="https://indianaiproduction.com/matplotlib-subplot" target="_blank" rel="noopener noreferrer">Subplots</a></strong></li>
<li><a href="https://indianaiproduction.com/matplotlib-savefig" target="_blank" rel="noopener noreferrer"><strong>Save Figure</strong></a></li>
<li><a href="https://indianaiproduction.com/matplotlib-imshow" target="_blank" rel="noopener noreferrer"><strong>Read &amp; Show Image</strong></a></li>
</ul>
<h4><img loading="lazy" decoding="async" class="aligncenter size-full wp-image-447" src="https://i0.wp.com/indianaiproduction.com/wp-content/uploads/2019/06/Python-Matplotlib-Tutorial.png?resize=1200%2C675&#038;ssl=1" alt="Python Matplotlib Tutorial" width="1200" height="675" srcset="https://i0.wp.com/indianaiproduction.com/wp-content/uploads/2019/06/Python-Matplotlib-Tutorial.png?w=1280&amp;ssl=1 1280w, https://i0.wp.com/indianaiproduction.com/wp-content/uploads/2019/06/Python-Matplotlib-Tutorial.png?resize=300%2C169&amp;ssl=1 300w, https://i0.wp.com/indianaiproduction.com/wp-content/uploads/2019/06/Python-Matplotlib-Tutorial.png?resize=768%2C432&amp;ssl=1 768w, https://i0.wp.com/indianaiproduction.com/wp-content/uploads/2019/06/Python-Matplotlib-Tutorial.png?resize=1024%2C576&amp;ssl=1 1024w" sizes="(max-width: 1200px) 100vw, 1200px" data-recalc-dims="1" /></h4>
<h4>Why use matplotlib?</h4>
<p>As a <a href="https://indianaiproduction.com/machine-learning/" target="_blank" rel="noopener noreferrer">machine learning</a> engineer or <a href="https://indianaiproduction.com/data-science/" target="_blank" rel="noopener noreferrer">data scientist,</a> data analysis is a part of model development.  Looking numeric data, you can&#8217;t get correct insights. So the best way to plot a graph using that data and take a decision for further process. Data visualization is a process take after the data cleaning.</p>
<h3>History of matplotlib</h3>
<p>The American neurologist <a href="https://en.wikipedia.org/wiki/John_D._Hunter" target="_blank" rel="noopener noreferrer"><b>John D. Hunter </b></a><em>(1968 &#8211; 2012), </em>wanted to draw some graph regarding their project. This was the main reason to develop matplotlib python graph plotting library. The matplotlib has written in the <a href="https://www.python.org" target="_blank" rel="noopener noreferrer">Python</a> programming language. As initially, It had been released in 2003. Now, matplotlib is the popular graph plotting library.</p>
<p>For more details, jump on the official site of <a href="https://matplotlib.org/3.1.0/users/history.html" target="_blank" rel="noopener noreferrer">matplotlib</a>.</p>
<figure style="width: 445px" class="wp-caption aligncenter"><a href="https://i0.wp.com/raw.githubusercontent.com/fperez/blog/master/fig/johnhunter-head.jpg?ssl=1"><img loading="lazy" decoding="async" src="https://i0.wp.com/raw.githubusercontent.com/fperez/blog/master/fig/johnhunter-head.jpg?resize=445%2C597&#038;ssl=1" alt="John D. Hunter" width="445" height="597" data-recalc-dims="1" /></a><figcaption class="wp-caption-text">John D. Hunter</figcaption></figure>
<p> </p>
<h3>Dependency of Matplotlib</h3>
<p>The matplotlib is depended on some third-party python library like <a href="https://indianaiproduction.com/python-numpy-tutorial/" target="_blank" rel="noopener noreferrer">NumPy</a>.</p>



<h3>Download and Install Matplotlib</h3>
<p>The matplotlib installation process is very simple. If you are using <a href="https://www.anaconda.com/distribution/">Anaconda Navigator</a>, then no need to install matplotlib. If you are using Python idle, PyCharm, Sublime Text, etc, then follow the below steps.</p>
<p>Open the command prompt or terminal and enter</p>


<div class="wp-block-syntaxhighlighter-code "><pre class="brush: plain; title: ; notranslate">
pip install matplotlib
</pre></div>


<p>and press <strong>Enter key </strong>to download and install matplotlib. The <strong>pip</strong> is a package, which installs the matplotlib python library.</p>



<h3>Importing Matplotlib</h3>
<p>For plotting graph, need to import matplotlib in the python file. Here is two way to import matplotlib given below.</p>


<div class="wp-block-syntaxhighlighter-code "><pre class="brush: python; title: ; notranslate">
from matplotlib import pyplot as plt # importing pyplot module from matplotlib library
# or
import matplotlib.pyplot as plt #  importing pyplot module from 
</pre></div>


<p>In the above code, we import the pyplot module from matplotlib for plot the graphs, like histogram, bar chart, pie plot, etc.</p>


<div class="su-divider su-divider-style-default" style="margin:15px 0;border-width:3px;border-color:#999999"><a href="#" style="color:#999999">Go to top</a></div>



<p><strong>The official study material for matplotlib</strong></p>
<p>Matplotlib Tutorial &#8211; <a href="https://matplotlib.org/3.1.0/tutorials/index.html">click here</a></p>


<div class="su-button-center"><a href="https://matplotlib.org/2.0.2/Matplotlib.pdf" class="su-button su-button-style-3d" style="color:#FFFFFF;background-color:#38bb04;border-color:#2d9604;border-radius:24px" target="_self"><span style="color:#FFFFFF;padding:5px 14px;font-size:12px;line-height:18px;border-color:#74d050;border-radius:24px;text-shadow:none"><i class="sui sui-cloud-download" style="font-size:12px;color:#FFFFFF"></i> Download Matplotlib 2.0.2 Tutorial PDF</span></a></div>


<div class="su-divider su-divider-style-default" style="margin:15px 0;border-width:3px;border-color:#999999"><a href="#" style="color:#999999">Go to top</a></div>



<h3>Conclusion</h3>
<p>I hope, you followed the python matplotlib tutorial and did practical. I am suggesting to you, try to use all the parameters of each method for a better understanding.</p>



<blockquote class="wp-block-quote"><p>After completion of the matplotlib tutorial jump on python <a rel="noreferrer noopener" aria-label="seaborn tutorial (opens in a new tab)" href="https://indianaiproduction.com/python-seaborn-tutorial-mastery-seaborn-library/" target="_blank"><strong>seaborn tutorial</strong></a><strong>. </strong>It is advance python data visualization library build on top of the matplotlib. </p></blockquote>
<p>The post <a rel="nofollow" href="https://indianaiproduction.com/python-matplotlib-tutorial/">Python Matplotlib Tutorial &#8211; Mastery in Matplotlib Library</a> appeared first on <a rel="nofollow" href="https://indianaiproduction.com">Indian AI Production</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://indianaiproduction.com/python-matplotlib-tutorial/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
		<post-id xmlns="com-wordpress:feed-additions:1">438</post-id>	</item>
	</channel>
</rss>

<!--
Performance optimized by W3 Total Cache. Learn more: https://www.boldgrid.com/w3-total-cache/

Page Caching using Disk: Enhanced 

Served from: indianaiproduction.com @ 2026-07-13 01:44:49 by W3 Total Cache
-->