

{"id":21529,"date":"2018-07-17T04:10:35","date_gmt":"2018-07-17T04:10:35","guid":{"rendered":"https:\/\/data-flair.training\/blogs\/?p=21529"},"modified":"2026-04-29T12:25:50","modified_gmt":"2026-04-29T06:55:50","slug":"python-matplotlib-tutorial","status":"publish","type":"post","link":"https:\/\/data-flair.training\/blogs\/python-matplotlib-tutorial\/","title":{"rendered":"Matplotlib in Python Tutorial &#8211; Python Plotting For Beginners"},"content":{"rendered":"<p>In our previous tutorial,\u00a0<a href=\"https:\/\/data-flair.training\/blogs\/python-data-cleansing\/\" target=\"_blank\" rel=\"noopener\"><strong>Python Data Cleansing<\/strong><\/a>. Today, we\u2019ll play around with Python Matplotlib Tutorial and Python Plot. Moreover, we will discuss Pyplot, Keyword String, and Categorical Variables of Python Plotting. At last, we will cover Line properties and some Python Matplotlib examples.<br \/>\nSo, let&#8217;s start Python Matplotlib Tutorial.<\/p>\n<h3>What is Python Matplotlib?<\/h3>\n<p>Working across platforms, when you want to conceive publication-quality figures in hardcopy formats and interactive environments, you use matplotlib. This is a library for 2-dimensional plotting with Python.<\/p>\n<p>Some plots it will let us build are:<\/p>\n<ul>\n<li>Plots<\/li>\n<li>Histograms<\/li>\n<li>Error charts<\/li>\n<li>Power spectra<\/li>\n<li>Bar charts<\/li>\n<li>Scatter Plots<\/li>\n<\/ul>\n<p>Some features of Python Plot support-<\/p>\n<ul>\n<li>Font properties<\/li>\n<li>Axes properties<\/li>\n<li>Line styles<\/li>\n<\/ul>\n<p><strong><a href=\"https:\/\/data-flair.training\/blogs\/python-packages\/\" target=\"_blank\" rel=\"noopener\">Follow this link to know about Python Packages\u00a0<\/a><\/strong><\/p>\n<h3 class=\"western\">Prerequisites of Python Matplotlib<\/h3>\n<p>For our Python Matplotlib tutorial, we will need two<a href=\"https:\/\/data-flair.training\/blogs\/python-library\/\" target=\"_blank\" rel=\"noopener\"><strong> Python libraries<\/strong><\/a>.<\/p>\n<h4 class=\"western\">a. Python Matplotlib<\/h4>\n<p>We\u2019ve already discussed this in section 2. To install it, you can use the following command-<\/p>\n<pre class=\"EnlighterJSRAW\">C:\\Users\\lifei&gt;pip install matplotlib<\/pre>\n<h4 class=\"western\">b. Python Pandas<\/h4>\n<p>Pandas is another Python library we will use here. It lets us manipulate and analyze data using data structures and operations on numerical tables and time series.<\/p>\n<div id=\"attachment_21609\" style=\"width: 610px\" class=\"wp-caption aligncenter\"><a href=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2018\/07\/pandas-4.png\"><img loading=\"lazy\" decoding=\"async\" aria-describedby=\"caption-attachment-21609\" class=\"wp-image-21609 size-full\" src=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2018\/07\/pandas-4.png\" alt=\"Python Matplotlib Tutorial - Python Plotting\" width=\"600\" height=\"125\" srcset=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2018\/07\/pandas-4.png 600w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2018\/07\/pandas-4-150x31.png 150w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2018\/07\/pandas-4-300x63.png 300w\" sizes=\"auto, (max-width: 600px) 100vw, 600px\" \/><\/a><p id=\"caption-attachment-21609\" class=\"wp-caption-text\">Matplotlib Tutorial &#8211; Python Plotting<\/p><\/div>\n<p>You can install it with the following command-<\/p>\n<pre class=\"EnlighterJSRAW\">C:\\Users\\lifei&gt;pip install pandas<\/pre>\n<h3>Pyplot in Python Matplotlib<\/h3>\n<p>It has a pyplot interface. This holds command-like functions that let us alter a figure.<\/p>\n<h4 class=\"western\">a. plot() in Matplotlib<\/h4>\n<p>You can use the plot() method to create a plot of points on the graph.<\/p>\n<pre class=\"EnlighterJSRAW\">&gt;&gt;&gt; import matplotlib.pyplot as plt\r\n&gt;&gt;&gt; plt.plot([2,3,4,5])<\/pre>\n<p><strong>[&lt;matplotlib.lines.Line2D object at 0x00FD5650&gt;]<\/strong><\/p>\n<pre class=\"EnlighterJSRAW\">&gt;&gt;&gt; plt.xlabel('Actual birth weight')<\/pre>\n<p><strong>Text(0.5,0,&#8217;Actual birth weight&#8217;)<\/strong><\/p>\n<pre class=\"EnlighterJSRAW\">&gt;&gt;&gt; plt.ylabel('Estimated birth weight')<\/pre>\n<p><strong>Text(0,0.5,&#8217;Estimated birth weight&#8217;)<\/strong><\/p>\n<pre class=\"EnlighterJSRAW\">&gt;&gt;&gt; plt.show()<\/pre>\n<p><strong><a href=\"https:\/\/data-flair.training\/blogs\/python-property-problem-solution\/\" target=\"_blank\" rel=\"noopener\">Let&#8217;s explore Python Property \u2013 The Problem and Solution<\/a><\/strong><\/p>\n<div id=\"attachment_21610\" style=\"width: 970px\" class=\"wp-caption aligncenter\"><a href=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2018\/07\/plot.png\"><img loading=\"lazy\" decoding=\"async\" aria-describedby=\"caption-attachment-21610\" class=\"wp-image-21610 size-full\" src=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2018\/07\/plot.png\" alt=\"Python Matplotlib Tutorial - Python Plotting\" width=\"960\" height=\"816\" srcset=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2018\/07\/plot.png 960w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2018\/07\/plot-150x128.png 150w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2018\/07\/plot-300x255.png 300w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2018\/07\/plot-768x653.png 768w\" sizes=\"auto, (max-width: 960px) 100vw, 960px\" \/><\/a><p id=\"caption-attachment-21610\" class=\"wp-caption-text\">Python Matplotlib Tutorial &#8211; Python Plotting<\/p><\/div>\n<p>Here, the methods xlabel() and ylabel() let us set labels for the x and y axes, respectively. It takes values from our list of parameters for the y-axis; for the x-axis, it uses 0.0, 1.0, 2.0, and 3.0 for the four points.<\/p>\n<p>We can give it more than one list of parameters-<\/p>\n<pre class=\"EnlighterJSRAW\">&gt;&gt;&gt; plt.plot([2,3,4,5],[3,8,10,12])<\/pre>\n<p><strong>[&lt;matplotlib.lines.Line2D object at 0x0153EFF0&gt;]\u00a0<\/strong><\/p>\n<pre class=\"EnlighterJSRAW\">&gt;&gt;&gt; plt.show()<\/pre>\n<div id=\"attachment_21611\" style=\"width: 971px\" class=\"wp-caption aligncenter\"><a href=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2018\/07\/plot2.png\"><img loading=\"lazy\" decoding=\"async\" aria-describedby=\"caption-attachment-21611\" class=\"wp-image-21611 size-full\" src=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2018\/07\/plot2.png\" alt=\"Python Matplotlib Tutorial - Python Plotting\" width=\"961\" height=\"821\" srcset=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2018\/07\/plot2.png 961w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2018\/07\/plot2-150x128.png 150w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2018\/07\/plot2-300x256.png 300w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2018\/07\/plot2-768x656.png 768w\" sizes=\"auto, (max-width: 961px) 100vw, 961px\" \/><\/a><p id=\"caption-attachment-21611\" class=\"wp-caption-text\">Python Matplotlib Tutorial &#8211; Python Plotting<\/p><\/div>\n<p>This takes the first list for the x-axis and the second for the y-axis.<\/p>\n<h4 class=\"western\">b. Formatting your Python Plot<\/h4>\n<p>A third argument will let you choose the color and the line type of the plot in Python Programming Language. The default format string gives us a solid blue line, as we\u2019ve seen in the examples so far. This is \u2018b-\u2018. You see, these strings are from MATLAB.<\/p>\n<pre class=\"EnlighterJSRAW\">&gt;&gt;&gt; plt.plot([2,3,4,5],[3,8,10,12],'gs')<\/pre>\n<p><strong>[&lt;matplotlib.lines.Line2D object at 0x01AD1050&gt;]<\/strong><\/p>\n<pre class=\"EnlighterJSRAW\">&gt;&gt;&gt; plt.axis([0,7,0,21])<\/pre>\n<p><strong>[0, 7, 0, 21]<\/strong><\/p>\n<pre class=\"EnlighterJSRAW\">&gt;&gt;&gt; plt.show()<\/pre>\n<div id=\"attachment_21613\" style=\"width: 973px\" class=\"wp-caption aligncenter\"><a href=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2018\/07\/format1.png\"><img loading=\"lazy\" decoding=\"async\" aria-describedby=\"caption-attachment-21613\" class=\"wp-image-21613 size-full\" src=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2018\/07\/format1.png\" alt=\"Python Matplotlib Tutorial - Python Plotting\" width=\"963\" height=\"821\" srcset=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2018\/07\/format1.png 963w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2018\/07\/format1-150x128.png 150w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2018\/07\/format1-300x256.png 300w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2018\/07\/format1-768x655.png 768w\" sizes=\"auto, (max-width: 963px) 100vw, 963px\" \/><\/a><p id=\"caption-attachment-21613\" class=\"wp-caption-text\">Python Matplotlib Tutorial &#8211; Python Plotting<\/p><\/div>\n<p>Formatting your Python Plot. The axis() method lets us set the viewport for the axes in terms of xmin, xmax, ymin, and ymax. The format string \u2018gs\u2019 here gives us green squares. Similarly, we can plot green, red, and blue orbs, squares, and triangles too.<\/p>\n<p>Let\u2019s take another example.<br \/>\n<strong><a href=\"https:\/\/data-flair.training\/blogs\/cgi-programming-python\/\" target=\"_blank\" rel=\"noopener\">Read about CGI Programming in Python with Functions and Modules<\/a><\/strong><\/p>\n<pre class=\"EnlighterJSRAW\">&gt;&gt;&gt; import numpy as np\r\n&gt;&gt;&gt; t=np.arange(0,5,0.2)\r\n&gt;&gt;&gt; plt.plot(t,t,'r--',t,t**3,'b^',t,t**2,'gs')<\/pre>\n<p><strong>[&lt;matplotlib.lines.Line2D object at 0x0A66B670&gt;, &lt;matplotlib.lines.Line2D object at 0x0A66B7B0&gt;, &lt;matplotlib.lines.Line2D object at 0x0A66BA90&gt;]\u00a0<\/strong><\/p>\n<pre class=\"EnlighterJSRAW\">&gt;&gt;&gt; plt.show()<\/pre>\n<div id=\"attachment_21615\" style=\"width: 969px\" class=\"wp-caption aligncenter\"><a href=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2018\/07\/format2.png\"><img loading=\"lazy\" decoding=\"async\" aria-describedby=\"caption-attachment-21615\" class=\"wp-image-21615 size-full\" src=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2018\/07\/format2.png\" alt=\"Python Matplotlib Tutorial - Python Plotting\" width=\"959\" height=\"817\" srcset=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2018\/07\/format2.png 959w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2018\/07\/format2-150x128.png 150w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2018\/07\/format2-300x256.png 300w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2018\/07\/format2-768x654.png 768w\" sizes=\"auto, (max-width: 959px) 100vw, 959px\" \/><\/a><p id=\"caption-attachment-21615\" class=\"wp-caption-text\">Matplotlib Tutorial &#8211; Python Plotting<\/p><\/div>\n<h3 class=\"western\">Keyword Strings with Python Matplotlib<\/h3>\n<p>Using a <i>data<\/i> keyword argument, we can produce Python plots with strings that relate to some variables. We can access these variables with strings.<\/p>\n<pre class=\"EnlighterJSRAW\">&gt;&gt;&gt; data={'a':np.arange(50),\r\n'c':np.random.randint(0,50,50),\r\n'd':np.random.randn(50)}\r\n&gt;&gt;&gt; data['b']=data['a']+10*np.random.randn(50)\r\n&gt;&gt;&gt; data['d']=np.abs(data['d'])*100\r\n&gt;&gt;&gt; plt.scatter('a','b',c='c',s='d',data=data)<\/pre>\n<p><strong>&lt;matplotlib.collections.PathCollection object at 0x0A7E8AD0&gt;<\/strong><\/p>\n<pre class=\"EnlighterJSRAW\">&gt;&gt;&gt; plt.show()<\/pre>\n<div id=\"attachment_21616\" style=\"width: 973px\" class=\"wp-caption aligncenter\"><a href=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2018\/07\/keyword.png\"><img loading=\"lazy\" decoding=\"async\" aria-describedby=\"caption-attachment-21616\" class=\"wp-image-21616 size-full\" src=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2018\/07\/keyword.png\" alt=\"Python Matplotlib Tutorial - Python Plotting\" width=\"963\" height=\"821\" srcset=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2018\/07\/keyword.png 963w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2018\/07\/keyword-150x128.png 150w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2018\/07\/keyword-300x256.png 300w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2018\/07\/keyword-768x655.png 768w\" sizes=\"auto, (max-width: 963px) 100vw, 963px\" \/><\/a><p id=\"caption-attachment-21616\" class=\"wp-caption-text\">Matplotlib Tutorial -Keyword Strings<\/p><\/div>\n<h3 class=\"western\">Categorical Variables to Python Plotting<\/h3>\n<p>We can pass categorical variables to Python plotting functions.<\/p>\n<pre class=\"EnlighterJSRAW\">&gt;&gt;&gt; names=[\"Dingos\",\"Wild Cats\",\"Tigers\"]\r\n&gt;&gt;&gt; values=[1,11,111]\r\n&gt;&gt;&gt; plt.figure(1,figsize=(9,3))<\/pre>\n<p><strong>&lt;Figure size 900&#215;300 with 0 Axes&gt;<\/strong><\/p>\n<pre class=\"EnlighterJSRAW\">&gt;&gt;&gt; plt.subplot(131)\r\n<\/pre>\n<p><strong>&lt;matplotlib.axes._subplots.AxesSubplot object at 0x00FD5B30&gt;<\/strong><\/p>\n<pre class=\"EnlighterJSRAW\">&gt;&gt;&gt; plt.bar(names,values)\r\n<\/pre>\n<p><strong>&lt;BarContainer object of 3 artists&gt;<\/strong><\/p>\n<pre class=\"EnlighterJSRAW\">&gt;&gt;&gt; plt.subplot(132)\r\n<\/pre>\n<p><strong>&lt;matplotlib.axes._subplots.AxesSubplot<\/strong> <strong>object at 0x01889610&gt;<\/strong><\/p>\n<pre class=\"EnlighterJSRAW\">&gt;&gt;&gt; plt.scatter(names,values)\r\n<\/pre>\n<p><strong>&lt;matplotlib.collections.PathCollection object at 0x0A191AB0&gt;<\/strong><\/p>\n<pre class=\"EnlighterJSRAW\">&gt;&gt;&gt; plt.subplot(133)\r\n<\/pre>\n<p><strong>&lt;matplotlib.axes._subplots.AxesSubplot<\/strong> <strong>object at 0x0A171110&gt;<\/strong><\/p>\n<pre class=\"EnlighterJSRAW\">&gt;&gt;&gt; plt.plot(names,values)\r\n<\/pre>\n<p><strong>[&lt;matplotlib.lines.Line2D object at 0x0A1ADE30&gt;]<\/strong><\/p>\n<pre class=\"EnlighterJSRAW\">&gt;&gt;&gt; plt.suptitle('Varsity')<\/pre>\n<p><strong>Text(0.5,0.98,&#8217;Varsity&#8217;)<\/strong><\/p>\n<pre class=\"EnlighterJSRAW\">&gt;&gt;&gt; plt.show()<\/pre>\n<div id=\"attachment_21618\" style=\"width: 1361px\" class=\"wp-caption aligncenter\"><a href=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2018\/07\/categorical.png\"><img loading=\"lazy\" decoding=\"async\" aria-describedby=\"caption-attachment-21618\" class=\"wp-image-21618 size-full\" src=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2018\/07\/categorical.png\" alt=\"Python Matplotlib Tutorial - Python Plotting\" width=\"1351\" height=\"548\" srcset=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2018\/07\/categorical.png 1351w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2018\/07\/categorical-150x61.png 150w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2018\/07\/categorical-300x122.png 300w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2018\/07\/categorical-768x312.png 768w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2018\/07\/categorical-1024x415.png 1024w\" sizes=\"auto, (max-width: 1351px) 100vw, 1351px\" \/><\/a><p id=\"caption-attachment-21618\" class=\"wp-caption-text\">Python Matplotlib Tutorial &#8211; Python Plotting<\/p><\/div>\n<p>Python Matplotlib Tutorial &#8211; Categorical Variables to Python Plotting<br \/>\n<strong><a href=\"https:\/\/data-flair.training\/blogs\/python-send-email\/\" target=\"_blank\" rel=\"noopener\">Do you know How Python sends email via SMTP | SMTP Server<\/a> <\/strong><\/p>\n<h3 class=\"western\">Some Line Properties of Matplotlib<\/h3>\n<p>Using some keyword arguments, we can alter how a graph looks. Let\u2019s look at some.<\/p>\n<div id=\"attachment_21653\" style=\"width: 1210px\" class=\"wp-caption aligncenter\"><a href=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2018\/07\/Line-Properties-of-Matplotlib-01.jpg\"><img loading=\"lazy\" decoding=\"async\" aria-describedby=\"caption-attachment-21653\" class=\"wp-image-21653 size-full\" src=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2018\/07\/Line-Properties-of-Matplotlib-01.jpg\" alt=\"Python Matplotlib Tutorial - Python Plotting For Beginners\" width=\"1200\" height=\"628\" srcset=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2018\/07\/Line-Properties-of-Matplotlib-01.jpg 1200w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2018\/07\/Line-Properties-of-Matplotlib-01-150x79.jpg 150w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2018\/07\/Line-Properties-of-Matplotlib-01-300x157.jpg 300w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2018\/07\/Line-Properties-of-Matplotlib-01-768x402.jpg 768w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2018\/07\/Line-Properties-of-Matplotlib-01-1024x536.jpg 1024w\" sizes=\"auto, (max-width: 1200px) 100vw, 1200px\" \/><\/a><p id=\"caption-attachment-21653\" class=\"wp-caption-text\">Python Matplotlib Tutorial &#8211; Line Properties<\/p><\/div>\n<h4 class=\"western\">a. Linewidth in Matplotlib<\/h4>\n<pre class=\"EnlighterJSRAW\">&gt;&gt;&gt; plt.plot([1,2,3],[2,4,9],linewidth=4.0)<\/pre>\n<p><strong>[&lt;matplotlib.lines.Line2D object at 0x010D05D0&gt;]\u00a0<\/strong><\/p>\n<pre class=\"EnlighterJSRAW\">&gt;&gt;&gt; plt.show()<\/pre>\n<div id=\"attachment_21620\" style=\"width: 975px\" class=\"wp-caption aligncenter\"><a href=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2018\/07\/linewidth.png\"><img loading=\"lazy\" decoding=\"async\" aria-describedby=\"caption-attachment-21620\" class=\"wp-image-21620 size-full\" src=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2018\/07\/linewidth.png\" alt=\"Python Matplotlib Tutorial - Python Plotting\" width=\"965\" height=\"817\" srcset=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2018\/07\/linewidth.png 965w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2018\/07\/linewidth-150x127.png 150w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2018\/07\/linewidth-300x254.png 300w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2018\/07\/linewidth-768x650.png 768w\" sizes=\"auto, (max-width: 965px) 100vw, 965px\" \/><\/a><p id=\"caption-attachment-21620\" class=\"wp-caption-text\">Python Matplotlib Tutorial &#8211;\u00a0Linewidth<\/p><\/div>\n<h4 class=\"western\">b. Alpha in Matplotlib<\/h4>\n<p>We can use the alpha channel to create prettier plots by softening colors.<\/p>\n<pre class=\"EnlighterJSRAW\">&gt;&gt;&gt; plt.plot([1,2,3],[2,4,9],alpha=5.5)<\/pre>\n<p><strong>[&lt;matplotlib.lines.Line2D object at 0x00BC9310&gt;]\u00a0<\/strong><\/p>\n<pre class=\"EnlighterJSRAW\">&gt;&gt;&gt; plt.show()<\/pre>\n<div id=\"attachment_21621\" style=\"width: 973px\" class=\"wp-caption aligncenter\"><a href=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2018\/07\/alpha.png\"><img loading=\"lazy\" decoding=\"async\" aria-describedby=\"caption-attachment-21621\" class=\"wp-image-21621 size-full\" src=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2018\/07\/alpha.png\" alt=\"Python Matplotlib Tutorial - Python Plotting\" width=\"963\" height=\"821\" srcset=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2018\/07\/alpha.png 963w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2018\/07\/alpha-150x128.png 150w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2018\/07\/alpha-300x256.png 300w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2018\/07\/alpha-768x655.png 768w\" sizes=\"auto, (max-width: 963px) 100vw, 963px\" \/><\/a><p id=\"caption-attachment-21621\" class=\"wp-caption-text\">Python Matplotlib Tutorial &#8211; Alpha<\/p><\/div>\n<h4 class=\"western\">c. Antialiased in Matplotlib<\/h4>\n<p>If you look closely, the lines look quite smooth. But we can turn antialiasing off- this will show us the aliasing in the lines.<\/p>\n<pre class=\"EnlighterJSRAW\">&gt;&gt;&gt; plt.plot([1,2,3],[2,4,9],antialiased=True)<\/pre>\n<p><strong>[&lt;matplotlib.lines.Line2D object at 0x087278B0&gt;]\u00a0<\/strong><\/p>\n<pre class=\"EnlighterJSRAW\">&gt;&gt;&gt; plt.show()<\/pre>\n<div id=\"attachment_21622\" style=\"width: 971px\" class=\"wp-caption aligncenter\"><a href=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2018\/07\/antialiased.png\"><img loading=\"lazy\" decoding=\"async\" aria-describedby=\"caption-attachment-21622\" class=\"wp-image-21622 size-full\" src=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2018\/07\/antialiased.png\" alt=\"Python Matplotlib Tutorial - Python Plotting\" width=\"961\" height=\"817\" srcset=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2018\/07\/antialiased.png 961w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2018\/07\/antialiased-150x128.png 150w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2018\/07\/antialiased-300x255.png 300w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2018\/07\/antialiased-768x653.png 768w\" sizes=\"auto, (max-width: 961px) 100vw, 961px\" \/><\/a><p id=\"caption-attachment-21622\" class=\"wp-caption-text\">Python Matplotlib Tutorial &#8211; Antialiased<\/p><\/div>\n<p><strong><a href=\"https:\/\/data-flair.training\/blogs\/image-processing-with-scipy-and-numpy\/\" target=\"_blank\" rel=\"noopener\">Let&#8217;s read about Image Processing with SciPy and NumPy in Python<\/a><\/strong><\/p>\n<h4 class=\"western\">d. Color or c in Matplotlib<\/h4>\n<p>You can set the color of the plot with this parameter.<\/p>\n<pre class=\"EnlighterJSRAW\">&gt;&gt;&gt; plt.plot([1,2,3],[2,4,9],color='Chartreuse')<\/pre>\n<p><strong>[&lt;matplotlib.lines.Line2D object at 0x0AE98D70&gt;]\u00a0<\/strong><\/p>\n<pre class=\"EnlighterJSRAW\">&gt;&gt;&gt; plt.show()<\/pre>\n<div id=\"attachment_21624\" style=\"width: 973px\" class=\"wp-caption aligncenter\"><a href=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2018\/07\/color.png\"><img loading=\"lazy\" decoding=\"async\" aria-describedby=\"caption-attachment-21624\" class=\"wp-image-21624 size-full\" src=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2018\/07\/color.png\" alt=\"Python Matplotlib Tutorial - Python Plotting\" width=\"963\" height=\"819\" srcset=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2018\/07\/color.png 963w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2018\/07\/color-150x128.png 150w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2018\/07\/color-300x255.png 300w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2018\/07\/color-768x653.png 768w\" sizes=\"auto, (max-width: 963px) 100vw, 963px\" \/><\/a><p id=\"caption-attachment-21624\" class=\"wp-caption-text\">Matplotlib Tutorial &#8211;\u00a0Color<\/p><\/div>\n<h4 class=\"western\">e. Dashes in Matplotlib<\/h4>\n<pre class=\"EnlighterJSRAW\">&gt;&gt;&gt; plt.plot([1,2,3],[2,4,9],dashes=[1,2,4,4])<\/pre>\n<p><strong>[&lt;matplotlib.lines.Line2D object at 0x099ED290&gt;]\u00a0<\/strong><\/p>\n<pre class=\"EnlighterJSRAW\">&gt;&gt;&gt; plt.show()<\/pre>\n<div id=\"attachment_21625\" style=\"width: 970px\" class=\"wp-caption aligncenter\"><a href=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2018\/07\/dashes.png\"><img loading=\"lazy\" decoding=\"async\" aria-describedby=\"caption-attachment-21625\" class=\"wp-image-21625 size-full\" src=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2018\/07\/dashes.png\" alt=\"Python Matplotlib Tutorial - Python Plotting\" width=\"960\" height=\"816\" srcset=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2018\/07\/dashes.png 960w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2018\/07\/dashes-150x128.png 150w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2018\/07\/dashes-300x255.png 300w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2018\/07\/dashes-768x653.png 768w\" sizes=\"auto, (max-width: 960px) 100vw, 960px\" \/><\/a><p id=\"caption-attachment-21625\" class=\"wp-caption-text\">Python Dashes<\/p><\/div>\n<h4 class=\"western\">f. Linestyle or ls in Matplotlib<\/h4>\n<p>You can choose the style of line you want for your plot.<\/p>\n<pre class=\"EnlighterJSRAW\">&gt;&gt;&gt; plt.plot([1,2,3],[2,4,9],linestyle='steps')<\/pre>\n<p><strong>[&lt;matplotlib.lines.Line2D object at 0x00B816D0&gt;]<\/strong><\/p>\n<pre class=\"EnlighterJSRAW\">&gt;&gt;&gt; plt.show()<\/pre>\n<div id=\"attachment_21630\" style=\"width: 969px\" class=\"wp-caption aligncenter\"><a href=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2018\/07\/steps.png\"><img loading=\"lazy\" decoding=\"async\" aria-describedby=\"caption-attachment-21630\" class=\"wp-image-21630 size-full\" src=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2018\/07\/steps.png\" alt=\"Python Matplotlib Tutorial - Python Plotting\" width=\"959\" height=\"821\" srcset=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2018\/07\/steps.png 959w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2018\/07\/steps-150x128.png 150w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2018\/07\/steps-300x257.png 300w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2018\/07\/steps-768x657.png 768w\" sizes=\"auto, (max-width: 959px) 100vw, 959px\" \/><\/a><p id=\"caption-attachment-21630\" class=\"wp-caption-text\">Python Matplotlib Tutorial &#8211; Linestyle\u00a0or ls<\/p><\/div>\n<pre class=\"EnlighterJSRAW\">&gt;&gt;&gt; plt.plot([1,2,3],[2,4,9],linestyle=':')<\/pre>\n<p><strong>[&lt;matplotlib.lines.Line2D object at 0x0AC892D0&gt;]\u00a0<\/strong><\/p>\n<pre class=\"EnlighterJSRAW\">&gt;&gt;&gt; plt.show()<\/pre>\n<div id=\"attachment_21628\" style=\"width: 969px\" class=\"wp-caption aligncenter\"><a href=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2018\/07\/linestyle-2.png\"><img loading=\"lazy\" decoding=\"async\" aria-describedby=\"caption-attachment-21628\" class=\"wp-image-21628 size-full\" src=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2018\/07\/linestyle-2.png\" alt=\"Python Matplotlib Tutorial - Python Plotting\" width=\"959\" height=\"817\" srcset=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2018\/07\/linestyle-2.png 959w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2018\/07\/linestyle-2-150x128.png 150w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2018\/07\/linestyle-2-300x256.png 300w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2018\/07\/linestyle-2-768x654.png 768w\" sizes=\"auto, (max-width: 959px) 100vw, 959px\" \/><\/a><p id=\"caption-attachment-21628\" class=\"wp-caption-text\">Matplotlib Tutorial &#8211; Python Linestyle\u00a0or ls<\/p><\/div>\n<p><strong><a href=\"https:\/\/data-flair.training\/blogs\/python-database-access\/\" target=\"_blank\" rel=\"noopener\">Let&#8217;s explore Python Database Access \u2013 Python 3 MySQL<\/a><\/strong><\/p>\n<h4 class=\"western\">g. Marker in Matplotlib<\/h4>\n<p>A marker will let you select what symbol you want to display at breakpoints and bends.<\/p>\n<pre class=\"EnlighterJSRAW\">&gt;&gt;&gt; plt.plot([1,2,3],[2,4,9],marker='+')<\/pre>\n<p><strong>[&lt;matplotlib.lines.Line2D object at 0x01018790&gt;]<\/strong><\/p>\n<pre class=\"EnlighterJSRAW\">&gt;&gt;&gt; plt.show()<\/pre>\n<div id=\"attachment_21631\" style=\"width: 971px\" class=\"wp-caption aligncenter\"><a href=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2018\/07\/marker.png\"><img loading=\"lazy\" decoding=\"async\" aria-describedby=\"caption-attachment-21631\" class=\"wp-image-21631 size-full\" src=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2018\/07\/marker.png\" alt=\"Python Matplotlib Tutorial - Python Plotting\" width=\"961\" height=\"819\" srcset=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2018\/07\/marker.png 961w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2018\/07\/marker-150x128.png 150w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2018\/07\/marker-300x256.png 300w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2018\/07\/marker-768x655.png 768w\" sizes=\"auto, (max-width: 961px) 100vw, 961px\" \/><\/a><p id=\"caption-attachment-21631\" class=\"wp-caption-text\">Python Marker<\/p><\/div>\n<h4 class=\"western\">h. Markeredgecolor in Matplotlib<\/h4>\n<p>You can also decide on a color for your markers\u2019 edges.<\/p>\n<pre class=\"EnlighterJSRAW\">&gt;&gt;&gt; plt.plot([1,2,3],[2,4,9],marker='+',markeredgecolor='brown')<\/pre>\n<p><strong>[&lt;matplotlib.lines.Line2D object at 0x01280110&gt;]\u00a0<\/strong><\/p>\n<pre class=\"EnlighterJSRAW\">&gt;&gt;&gt; plt.show()<\/pre>\n<div id=\"attachment_21635\" style=\"width: 970px\" class=\"wp-caption aligncenter\"><a href=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2018\/07\/1-14.png\"><img loading=\"lazy\" decoding=\"async\" aria-describedby=\"caption-attachment-21635\" class=\"wp-image-21635 size-full\" src=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2018\/07\/1-14.png\" alt=\"Python Matplotlib Tutorial - Python Plotting\" width=\"960\" height=\"814\" srcset=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2018\/07\/1-14.png 960w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2018\/07\/1-14-150x127.png 150w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2018\/07\/1-14-300x254.png 300w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2018\/07\/1-14-768x651.png 768w\" sizes=\"auto, (max-width: 960px) 100vw, 960px\" \/><\/a><p id=\"caption-attachment-21635\" class=\"wp-caption-text\">Matplotlib Tutorial &#8211; Markeredgecolor<\/p><\/div>\n<h4>i. Markeredgewidth in Matplotlib<\/h4>\n<p>This lets us decide how thick we want our markers to be.<\/p>\n<pre class=\"EnlighterJSRAW\">&gt;&gt;&gt; plt.plot([1,2,3],[2,4,9],marker='+',markeredgewidth=0.4)<\/pre>\n<p><strong>[&lt;matplotlib.lines.Line2D object at 0x0AE54290&gt;]<\/strong><\/p>\n<pre class=\"EnlighterJSRAW\">&gt;&gt;&gt; plt.show()<\/pre>\n<div id=\"attachment_21637\" style=\"width: 970px\" class=\"wp-caption aligncenter\"><img loading=\"lazy\" decoding=\"async\" aria-describedby=\"caption-attachment-21637\" class=\"wp-image-21637 size-full\" src=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2018\/07\/2-12.png\" alt=\"Python Matplotlib Tutorial - Python Plotting\" width=\"960\" height=\"822\" srcset=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2018\/07\/2-12.png 960w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2018\/07\/2-12-150x128.png 150w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2018\/07\/2-12-300x257.png 300w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2018\/07\/2-12-768x658.png 768w\" sizes=\"auto, (max-width: 960px) 100vw, 960px\" \/><p id=\"caption-attachment-21637\" class=\"wp-caption-text\">Matplotlib Tutorial &#8211; Markeredgewidth<\/p><\/div>\n<p><strong><a href=\"https:\/\/data-flair.training\/blogs\/data-wrangling-with-python\/\" target=\"_blank\" rel=\"noopener\">Let&#8217;s Learn Aggregation and Data Wrangling with Python<\/a><\/strong><\/p>\n<h4 class=\"western\">j. Markerfacecolor and Markersize in Matplotlib<\/h4>\n<p>This will let you choose which color to fill in your marker and what size to keep it.<\/p>\n<pre class=\"EnlighterJSRAW\">&gt;&gt;&gt; plt.plot([1,2,3],[2,4,9],marker='.',markerfacecolor='orange',markersize=13.0)<\/pre>\n<p><strong>[&lt;matplotlib.lines.Line2D object at 0x0AE9BC10&gt;]\u00a0<\/strong><\/p>\n<pre class=\"EnlighterJSRAW\">&gt;&gt;&gt; plt.show()<\/pre>\n<div id=\"attachment_21638\" style=\"width: 968px\" class=\"wp-caption aligncenter\"><a href=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2018\/07\/3-11.png\"><img loading=\"lazy\" decoding=\"async\" aria-describedby=\"caption-attachment-21638\" class=\"wp-image-21638 size-full\" src=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2018\/07\/3-11.png\" alt=\"Python Matplotlib Tutorial - Python Plotting\" width=\"958\" height=\"816\" srcset=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2018\/07\/3-11.png 958w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2018\/07\/3-11-150x128.png 150w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2018\/07\/3-11-300x256.png 300w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2018\/07\/3-11-768x654.png 768w\" sizes=\"auto, (max-width: 958px) 100vw, 958px\" \/><\/a><p id=\"caption-attachment-21638\" class=\"wp-caption-text\">Python Matplotlib Tutorial &#8211; Markerfacecolor and Markersize<\/p><\/div>\n<h4 class=\"western\">k. Markevery in Matplotlib<\/h4>\n<p>This parameter lets us decide at what parameters we want to put markers.<\/p>\n<div id=\"attachment_21640\" style=\"width: 971px\" class=\"wp-caption aligncenter\"><a href=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2018\/07\/marker-1.png\"><img loading=\"lazy\" decoding=\"async\" aria-describedby=\"caption-attachment-21640\" class=\"wp-image-21640 size-full\" src=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2018\/07\/marker-1.png\" alt=\"Python Matplotlib Tutorial - Python Plotting\" width=\"961\" height=\"819\" srcset=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2018\/07\/marker-1.png 961w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2018\/07\/marker-1-150x128.png 150w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2018\/07\/marker-1-300x256.png 300w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2018\/07\/marker-1-768x655.png 768w\" sizes=\"auto, (max-width: 961px) 100vw, 961px\" \/><\/a><p id=\"caption-attachment-21640\" class=\"wp-caption-text\">Python Markevery<\/p><\/div>\n<pre class=\"EnlighterJSRAW\">plt.plot([1,2,3],[2,4,9],marker='.',markerfacecolor='orange',markersize=13.0,markevery=2)<\/pre>\n<p>[&lt;matplotlib.lines.Line2D object at 0x0103C8B0&gt;]<\/p>\n<pre class=\"EnlighterJSRAW\">&gt;&gt;&gt; plt.show()<\/pre>\n<pre class=\"EnlighterJSRAW\">&gt;&gt;&gt; plt.plot([1,2,3],<\/pre>\n<p><strong>[2,4,9],marker=&#8217;.&#8217;,markerfacecolor=&#8217;orange&#8217;,markersize=13.0,markevery=3) [&lt;matplotlib.lines.Line2D object at 0x01025F10&gt;]<\/strong><\/p>\n<pre class=\"EnlighterJSRAW\">&gt;&gt;&gt; plt.show()<\/pre>\n<div id=\"attachment_21642\" style=\"width: 966px\" class=\"wp-caption aligncenter\"><a href=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2018\/07\/markevery1.png\"><img loading=\"lazy\" decoding=\"async\" aria-describedby=\"caption-attachment-21642\" class=\"wp-image-21642 size-full\" src=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2018\/07\/markevery1.png\" alt=\"Python Matplotlib Tutorial - Python Plotting\" width=\"956\" height=\"816\" srcset=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2018\/07\/markevery1.png 956w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2018\/07\/markevery1-150x128.png 150w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2018\/07\/markevery1-300x256.png 300w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2018\/07\/markevery1-768x656.png 768w\" sizes=\"auto, (max-width: 956px) 100vw, 956px\" \/><\/a><p id=\"caption-attachment-21642\" class=\"wp-caption-text\">Matplotlib Tutorial &#8211; Python Markevery<\/p><\/div>\n<h4 class=\"western\">l. Zorder in Matplotlib<\/h4>\n<p>This lets us decide which plots will show up in the front and which to send to back.<\/p>\n<pre class=\"EnlighterJSRAW\">&gt;&gt;&gt; plt.plot([1,2,3],[2,4,9],zorder=1,linewidth=4)<\/pre>\n<p><strong>[&lt;matplotlib.lines.Line2D object at 0x01255E70&gt;]<\/strong><\/p>\n<pre class=\"EnlighterJSRAW\">&gt;&gt;&gt; plt.plot([1,2,6,9],[2,4,9,10],zorder=2,linewidth=4)<\/pre>\n<p><strong>[&lt;matplotlib.lines.Line2D object at 0x01255770&gt;]<\/strong><\/p>\n<pre class=\"EnlighterJSRAW\">&gt;&gt;&gt; plt.show()<\/pre>\n<div id=\"attachment_21644\" style=\"width: 970px\" class=\"wp-caption aligncenter\"><a href=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2018\/07\/zorder.png\"><img loading=\"lazy\" decoding=\"async\" aria-describedby=\"caption-attachment-21644\" class=\"wp-image-21644 size-full\" src=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2018\/07\/zorder.png\" alt=\"Python Matplotlib Tutorial - Python Plotting\" width=\"960\" height=\"816\" srcset=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2018\/07\/zorder.png 960w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2018\/07\/zorder-150x128.png 150w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2018\/07\/zorder-300x255.png 300w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2018\/07\/zorder-768x653.png 768w\" sizes=\"auto, (max-width: 960px) 100vw, 960px\" \/><\/a><p id=\"caption-attachment-21644\" class=\"wp-caption-text\">Matplotlib Tutorial &#8211; Python Plotting<\/p><\/div>\n<p>In this graph, in the area enclosed by the points (1,2) and (2,4), both plots cover the same points, but the one in orange is in the front. This is because we give it a higher zorder. This is like z-index in CSS.<br \/>\n<strong><a href=\"https:\/\/data-flair.training\/blogs\/python-stemming\/\" target=\"_blank\" rel=\"noopener\">Let&#8217;s Know about Python Stemming and Lemmatization \u2013 NLTK<\/a> <\/strong><\/p>\n<h3 class=\"western\">Showing a Grid in Python Plot<\/h3>\n<p>You can use the grid() method to toggle a grid in your plot.<\/p>\n<pre class=\"EnlighterJSRAW\">&gt;&gt;&gt; plt.grid(True)\r\n&gt;&gt;&gt; plt.plot([1,2,6,9],[2,4,9,10],zorder=2,linewidth=4)<\/pre>\n<p><strong>[&lt;matplotlib.lines.Line2D object at 0x00DC02B0&gt;]\u00a0<\/strong><\/p>\n<pre class=\"EnlighterJSRAW\">&gt;&gt;&gt; plt.show()<\/pre>\n<div id=\"attachment_21646\" style=\"width: 972px\" class=\"wp-caption aligncenter\"><a href=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2018\/07\/grid.png\"><img loading=\"lazy\" decoding=\"async\" aria-describedby=\"caption-attachment-21646\" class=\"wp-image-21646 size-full\" src=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2018\/07\/grid.png\" alt=\"Python Matplotlib Tutorial - Python Plotting\" width=\"962\" height=\"818\" srcset=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2018\/07\/grid.png 962w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2018\/07\/grid-150x128.png 150w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2018\/07\/grid-300x255.png 300w, https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2018\/07\/grid-768x653.png 768w\" sizes=\"auto, (max-width: 962px) 100vw, 962px\" \/><\/a><p id=\"caption-attachment-21646\" class=\"wp-caption-text\">Showing a Grid in Python Plot<\/p><\/div>\n<p>So, this was all about Python Matplotlib Tutorial. Hope you like our explanation.<\/p>\n<h3>Conclusion<\/h3>\n<p>Matplotlib is the starting point for almost all the data visuals in Python. By learning it, you\u2019ve unlocked the ability to create everything from basic to a professional level. It\u2019s the ultimate tool for turning data into insights, which is really important.<\/p>\n<p>Hence, we have studied Matplotlib, which is a Python library used for plotting and much more. Libraries like Seaborn and Pandas plotting functions are built on top of Matplotlib. Once you understand the basics, you can use it to build visuals for dashboards, reports, and Jupyter notebooks that clearly communicate your insights.<\/p>\n<p>Furthermore, if you have any information regarding it, feel free to share it with us.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>In our previous tutorial,\u00a0Python Data Cleansing. Today, we\u2019ll play around with Python Matplotlib Tutorial and Python Plot. Moreover, we will discuss Pyplot, Keyword String, and Categorical Variables of Python Plotting. At last, we will&#46;&#46;&#46;<\/p>\n","protected":false},"author":5,"featured_media":21652,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[46],"tags":[422,727,2408,2640,3271,4875,8299,8300,8571,8573,8574,8575,8580,8604,10271,10677,10761,12858,15868,16435],"class_list":["post-21529","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-python","tag-alpha","tag-antialiased","tag-categorical-variables-to-python-plotting","tag-color-or-c","tag-dashes","tag-formatting-your-python-plot","tag-linestyle-or-ls","tag-linewidth","tag-marker","tag-markeredgecolor","tag-markeredgewidth","tag-markerfacecolor-and-markersize","tag-markevery","tag-matplotlib-in-python-programming","tag-pyplot","tag-python-matplotlib-tutorial","tag-python-plotting","tag-showing-a-grid-in-python-plot","tag-what-is-python-matplotlib","tag-zorder"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.4 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>Matplotlib in Python Tutorial - Python Plotting For Beginners - DataFlair<\/title>\n<meta name=\"description\" content=\"Let&#039;s learn what Matplotlib is in Python, how Python Plot List, Pyplot, and Categorical Variables work in Python.\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/data-flair.training\/blogs\/python-matplotlib-tutorial\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Matplotlib in Python Tutorial - Python Plotting For Beginners - DataFlair\" \/>\n<meta property=\"og:description\" content=\"Let&#039;s learn what Matplotlib is in Python, how Python Plot List, Pyplot, and Categorical Variables work in Python.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/data-flair.training\/blogs\/python-matplotlib-tutorial\/\" \/>\n<meta property=\"og:site_name\" content=\"DataFlair\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/DataFlairWS\/\" \/>\n<meta property=\"article:published_time\" content=\"2018-07-17T04:10:35+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2026-04-29T06:55:50+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2018\/07\/Python-Matplotlib-Tutorial-Python-Plotting-01.jpg\" \/>\n\t<meta property=\"og:image:width\" content=\"1200\" \/>\n\t<meta property=\"og:image:height\" content=\"628\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/jpeg\" \/>\n<meta name=\"author\" content=\"DataFlair Team\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@DataFlairWS\" \/>\n<meta name=\"twitter:site\" content=\"@DataFlairWS\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"DataFlair Team\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"10 minutes\" \/>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Matplotlib in Python Tutorial - Python Plotting For Beginners - DataFlair","description":"Let's learn what Matplotlib is in Python, how Python Plot List, Pyplot, and Categorical Variables work in Python.","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/data-flair.training\/blogs\/python-matplotlib-tutorial\/","og_locale":"en_US","og_type":"article","og_title":"Matplotlib in Python Tutorial - Python Plotting For Beginners - DataFlair","og_description":"Let's learn what Matplotlib is in Python, how Python Plot List, Pyplot, and Categorical Variables work in Python.","og_url":"https:\/\/data-flair.training\/blogs\/python-matplotlib-tutorial\/","og_site_name":"DataFlair","article_publisher":"https:\/\/www.facebook.com\/DataFlairWS\/","article_published_time":"2018-07-17T04:10:35+00:00","article_modified_time":"2026-04-29T06:55:50+00:00","og_image":[{"width":1200,"height":628,"url":"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2018\/07\/Python-Matplotlib-Tutorial-Python-Plotting-01.jpg","type":"image\/jpeg"}],"author":"DataFlair Team","twitter_card":"summary_large_image","twitter_creator":"@DataFlairWS","twitter_site":"@DataFlairWS","twitter_misc":{"Written by":"DataFlair Team","Est. reading time":"10 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/data-flair.training\/blogs\/python-matplotlib-tutorial\/#article","isPartOf":{"@id":"https:\/\/data-flair.training\/blogs\/python-matplotlib-tutorial\/"},"author":{"name":"DataFlair Team","@id":"https:\/\/data-flair.training\/blogs\/#\/schema\/person\/7f83c342f5d1632d6f7b4b0b0f447823"},"headline":"Matplotlib in Python Tutorial &#8211; Python Plotting For Beginners","datePublished":"2018-07-17T04:10:35+00:00","dateModified":"2026-04-29T06:55:50+00:00","mainEntityOfPage":{"@id":"https:\/\/data-flair.training\/blogs\/python-matplotlib-tutorial\/"},"wordCount":1527,"commentCount":1,"publisher":{"@id":"https:\/\/data-flair.training\/blogs\/#organization"},"image":{"@id":"https:\/\/data-flair.training\/blogs\/python-matplotlib-tutorial\/#primaryimage"},"thumbnailUrl":"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2018\/07\/Python-Matplotlib-Tutorial-Python-Plotting-01.jpg","keywords":["Alpha","Antialiased","Categorical Variables to Python Plotting","Color or c","Dashes","Formatting your Python Plot","Linestyle or ls","Linewidth","Marker","Markeredgecolor","Markeredgewidth","Markerfacecolor and Markersize","Markevery","Matplotlib in Python Programming","Pyplot","Python Matplotlib Tutorial","Python Plotting","Showing a Grid in Python Plot","What is Python Matplotlib","zorder"],"articleSection":["Python Tutorials"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/data-flair.training\/blogs\/python-matplotlib-tutorial\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/data-flair.training\/blogs\/python-matplotlib-tutorial\/","url":"https:\/\/data-flair.training\/blogs\/python-matplotlib-tutorial\/","name":"Matplotlib in Python Tutorial - Python Plotting For Beginners - DataFlair","isPartOf":{"@id":"https:\/\/data-flair.training\/blogs\/#website"},"primaryImageOfPage":{"@id":"https:\/\/data-flair.training\/blogs\/python-matplotlib-tutorial\/#primaryimage"},"image":{"@id":"https:\/\/data-flair.training\/blogs\/python-matplotlib-tutorial\/#primaryimage"},"thumbnailUrl":"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2018\/07\/Python-Matplotlib-Tutorial-Python-Plotting-01.jpg","datePublished":"2018-07-17T04:10:35+00:00","dateModified":"2026-04-29T06:55:50+00:00","description":"Let's learn what Matplotlib is in Python, how Python Plot List, Pyplot, and Categorical Variables work in Python.","breadcrumb":{"@id":"https:\/\/data-flair.training\/blogs\/python-matplotlib-tutorial\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/data-flair.training\/blogs\/python-matplotlib-tutorial\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/data-flair.training\/blogs\/python-matplotlib-tutorial\/#primaryimage","url":"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2018\/07\/Python-Matplotlib-Tutorial-Python-Plotting-01.jpg","contentUrl":"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2018\/07\/Python-Matplotlib-Tutorial-Python-Plotting-01.jpg","width":1200,"height":628,"caption":"Python Matplotlib Tutorial - Python Plotting For Beginners"},{"@type":"BreadcrumbList","@id":"https:\/\/data-flair.training\/blogs\/python-matplotlib-tutorial\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Blog Home","item":"https:\/\/data-flair.training\/blogs\/"},{"@type":"ListItem","position":2,"name":"Python Tutorials","item":"https:\/\/data-flair.training\/blogs\/category\/python\/"},{"@type":"ListItem","position":3,"name":"Matplotlib in Python Tutorial &#8211; Python Plotting For Beginners"}]},{"@type":"WebSite","@id":"https:\/\/data-flair.training\/blogs\/#website","url":"https:\/\/data-flair.training\/blogs\/","name":"DataFlair","description":"Learn Today. Lead Tomorrow.","publisher":{"@id":"https:\/\/data-flair.training\/blogs\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/data-flair.training\/blogs\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/data-flair.training\/blogs\/#organization","name":"DataFlair","url":"https:\/\/data-flair.training\/blogs\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/data-flair.training\/blogs\/#\/schema\/logo\/image\/","url":"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2016\/07\/Data-Flair.png","contentUrl":"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2016\/07\/Data-Flair.png","width":106,"height":48,"caption":"DataFlair"},"image":{"@id":"https:\/\/data-flair.training\/blogs\/#\/schema\/logo\/image\/"},"sameAs":["https:\/\/www.facebook.com\/DataFlairWS\/","https:\/\/x.com\/DataFlairWS","https:\/\/www.linkedin.com\/company\/dataflair-web-services-pvt-ltd\/","https:\/\/www.youtube.com\/user\/DataFlairWS"]},{"@type":"Person","@id":"https:\/\/data-flair.training\/blogs\/#\/schema\/person\/7f83c342f5d1632d6f7b4b0b0f447823","name":"DataFlair Team","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/secure.gravatar.com\/avatar\/4cf3a74600d131330b8c481d519afd1574093ed89f6d3396a95393ad223eb7cd?s=96&d=mm&r=g","url":"https:\/\/secure.gravatar.com\/avatar\/4cf3a74600d131330b8c481d519afd1574093ed89f6d3396a95393ad223eb7cd?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/4cf3a74600d131330b8c481d519afd1574093ed89f6d3396a95393ad223eb7cd?s=96&d=mm&r=g","caption":"DataFlair Team"},"description":"DataFlair Team creates expert-level guides on programming, Java, Python, C++, DSA, AI, ML, data Science, Android, Flutter, MERN, Web Development, and technology. Our goal is to empower learners with easy-to-understand content. Explore our resources for career growth and practical learning.","url":"https:\/\/data-flair.training\/blogs\/author\/dfteam1\/"}]}},"amp_enabled":true,"_links":{"self":[{"href":"https:\/\/data-flair.training\/blogs\/wp-json\/wp\/v2\/posts\/21529","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/data-flair.training\/blogs\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/data-flair.training\/blogs\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/data-flair.training\/blogs\/wp-json\/wp\/v2\/users\/5"}],"replies":[{"embeddable":true,"href":"https:\/\/data-flair.training\/blogs\/wp-json\/wp\/v2\/comments?post=21529"}],"version-history":[{"count":9,"href":"https:\/\/data-flair.training\/blogs\/wp-json\/wp\/v2\/posts\/21529\/revisions"}],"predecessor-version":[{"id":148067,"href":"https:\/\/data-flair.training\/blogs\/wp-json\/wp\/v2\/posts\/21529\/revisions\/148067"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/data-flair.training\/blogs\/wp-json\/wp\/v2\/media\/21652"}],"wp:attachment":[{"href":"https:\/\/data-flair.training\/blogs\/wp-json\/wp\/v2\/media?parent=21529"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/data-flair.training\/blogs\/wp-json\/wp\/v2\/categories?post=21529"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/data-flair.training\/blogs\/wp-json\/wp\/v2\/tags?post=21529"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}