Hello, my name is Nizar Dajani, and in these lessons, you will learn about Matplotlib, Seaborn, and Plotly. And in this lesson, you will learn about Matplotlib. Matplotlib is one of the most popular and certainly one of the most widely used data visualization libraries in Python. It is a multi-platform, multi-purpose, and highly customizable library capable of producing virtually any type of data visualization. It can generate line plots, scatter plots, bar plots, histograms, pie charts, and many more, all with just a few lines of code. Now, Matplotlib is not included in the standard Python library, so we need to first install it. I'll go ahead and open Terminal Window, and I'll type pip install matplotlib, then hit enter, and you can see from the output that I already have it installed, so we're good to use it in our code. I'll now switch back to my code examples, and you can see that I have many examples to show you, starting with a simple line plot. The first line of code imports the pieplot sub-package of the matplotlib library. Then I alias it with just PLT. Pieplot is the sub-package of matplotlib that contains all the different types of plots we need to create. Then I also import the NumPy library because I will use it to create the data that I will plot. Then on my next two lines, I will create the x and y variables to hold some data for my x and y axis. Then I will call the plot method of the pieplot sub-package, and pass in my data, which are my x and y variables. The bare minimum arguments for most plots will be the data, so these must be passed. Then I give my line plier title, then I need to call the show method to actually draw the line plot out. So let's run this code and see the magic appear. And there you go, with just a few lines of code, I was able to graph my data, giving me a visualization of all my raw data looks like. But let's not stop here. My next example will draw out what is known as a scatterplot. As the name implies, it will be data scattered all over our plot. My first four lines are very similar to the previous example where I import the needed libraries, followed by the definition of both the x and y data. In this case, I'm generating random numbers. Then I call the scatter method of the pieplot sub-package, and pass it my data values. But I also pass it to attributes. The color attribute is for the color of the dots that will appear in the scatter plot. And the edge color attribute is for the edge of the dots that will appear in the scatter plot. By the way, these two attributes can be used with most of the other plots. For instance, if I go back to my first code example and add the color attribute and set it equal to a red and then run it again, my line plot now changed colors accordingly. So these plots are highly customizable, and I'm only scratching the surface here. All right, back to the scatter plot example, I can also customize the label for my x-axis and my y-axis. And I'm also adding a title here. Then I show my plot. So let's run this code and see it in action. So my data is scattered all over the chart, hence the name scatter plot. And I see my title, as well as my x-label, and my y-label as well. And my dots are the color red with black edges. Okay, let's move on to the next example. And the first three lines you're familiar with by now, in fact, all code lines should be similar to you, except this one. This is where I create a histogram using the his method. The two arguments I'm passing is the data, which is always required, plus something called bins. A bin refers to the range of values that are divided into series of intervals. And bins are also sometimes called buckets. So each bin represents a specific interval of values, and the number of data points that fall into each bin are represented as the bars in the histogram. So in my example here, I have my data values to be divided into 30 bins. I'll go ahead and run this code to see what it looks like. So these are my bars spread across the range of my data values. I can also add the edge color attribute and set it equal to black, so I can get a better feel of my bins. Then I'll run this code again. And there you go. This might be a better view. Again, you can customize it as you wish. My next example will create a bar plot. I have my two data variables, which are categories and quantities. Then I call the bar method of the pyplots up package and pass in my x and y axis data. Then I have some customization for the title and x and y labels. So let's run this to see it unfold in front of our eyes. And there you go. A simple bar plot created with just a few lines of code. My next example will show a colorful pyplot. So I begin with the import statement. Then I define my data and other information. First, I have labels, which will be the different labels for each piece of the pie plot. Then I define my data, which is a list of random numbers. Then I create another list to hold the colors for each pie piece. Then I use an attribute called explode, which will have an interesting effect of my pie plot once it's drawn out. Then I call the py method of my pyplots up package and pass up my data and all the customizations. Then I call the show method so I can display the pie plot. And now let's run this code. And I get a crisp and professionally looking pie plot with my different labels, different values, different colors, and see how the yellow python pie stands out. This was all thanks to the explode attribute I defined earlier. And for my last example, I will show you subplots. You see, sometimes we want to create a plot with multiple subplots. So let me explain the code line by line so you can better understand this example. I start by importing the needed libraries. Then my next line. This generates 400 evenly spaced values from zero to two pie. These values will be used as the x coordinates for the points we will plot. Then we go to the next line of code. This generates the y coordinates by taking the sign of the square of each x coordinate. And onto the next line of code, this creates a new figure and adds two subplots to it. The two here means we want to create two subplots. The fig variable is the whole figure, while the axs variable is an array containing each subplot. Then the next line adds a title to the whole figure. Then the axs zero dot plot line This plots the data on the first subplot. While the next line draws the data on the second subplot. Then we just show our subplots. So let's run this code. We get two vertically stacked subplots. And I can also apply the color attribute to first subplot and set it equal to red. Then I'll run it again. And now the color for the first subplot has been updated accordingly. I can also control the thickness of the plotted line. For example, I'll add the attribute line width and set it equal to five. Then I'll run this code again. And now you see that the line's thickness has increased, making it more visible and stands out better. So in this lesson, you learned about data visualization using the matplot library. And next lesson, you'll learn about the seaborn library. Thanks for watching.