20,000+ Professional Language Experts Ready to Help. Expertise in a variety of Niches.
Unmatched expertise at affordable rates tailored for your needs. Our services empower you to boost your productivity.
GoTranscript is the chosen service for top media organizations, universities, and Fortune 50 companies.
Speed Up Research, 10% Discount
Ensure Compliance, Secure Confidentiality
Court-Ready Transcriptions
HIPAA-Compliant Accuracy
Boost your revenue
Streamline Your Team’s Communication
We're with you from start to finish, whether you're a first-time user or a long-time client.
Give Support a Call
+1 (831) 222-8398
Get a reply & call within 24 hours
Let's chat about how to work together
Direct line to our Head of Sales for bulk/API inquiries
Question about your orders with GoTranscript?
Ask any general questions about GoTranscript
Interested in working at GoTranscript?
Speaker 1: Hey hackers. Welcome back to my channel. My name is Katherine and today we're looking at Matplotlib. Matplotlib is a Python library that you can import and use to visualize your data. Today we're gonna be using a tool called Jupyter and what this is gonna do is it's gonna make our outputs more visual. If you want to use this too, all you have to do is write these two commands inside of your terminal and then once you have it installed you can just go Jupyter notebook and that will open it up for you in something like this and then inside of here it'll say you probably have no files and so you'll create a new file. You'll go Python 3 and you'll be right at this page. Before we can use Matplotlib, we have to import it. So we need to write import matplotlib.pyplot as plt and so this is gonna let us use it in the program. We're doing this percent sign matplotlib inline so that you can see the plots in the notebook. Next we need some data. So I'm gonna go x equals list range 0 through 10. This is gonna give us the numbers 0 through 9 and then we're gonna do the negative side of that as well. So range in this case negative 10 to 0. Now we're gonna plot x by y. So we're gonna graph the x data by the y data. We're gonna plot them using matplotlib. We're just gonna go plt.plot and then we want it x by y so we go x and then y and then we can save it up and go ahead and run this cell. To run the cell we just go shift enter and voila we have this beautiful plot x by y on this graph and we just used matplotlib for the first time. Now let's try it with some different data. We're gonna go a equals 0 negative 125 67 negative 323 or 323. Then we're gonna create our B data set which is gonna be 0 3 7 3 9. To plot them if you remember from before we did plt.plot a by b. We'll save it up because we want to graph a by b and we get this weird-looking diagram. It has a little triangle here and that is our output. That is a graph by b, a by b. Here we have the plot with matplotlib. So now we know about graphs. What if we wanted to try to plot this in a different way? Let's say I only want to focus on this triangle here. To do this I'm gonna set new axes. I'm gonna go plt.axis. First I'm gonna put in what I want my start and end for the x-axis to be and then I'm gonna put in what I want my start and end for the y-axis to be. The triangle here starts at about negative 50 so I'm gonna write negative 50 and then it kind of ends near 80 so I'm gonna write that in too. For the y-axis it really starts we'll say around 3 or 2 we'll go 2 and then it ends around 8. So we'll go 2 and 8. Then we'll go plt.plot a by b. We'll save it up. We'll hit enter again and now we're zoomed in on that triangle. Now let's say I want to add a label to this graph and so I want the top or the title of the graph to be triangle. To do that we can go plt.title triangle or whatever we want the title to be. We can also give the x and y axis labels by going plt.xlabel. We'll say it's array a because it's a by b. We're graphing a by b. The plot is a b and then we'll go pltylabel is gonna be our array b. We'll go ahead and do plt.plot a b and we'll see this plotted again but with array a down here, array b down here, triangle at the top and we're zoomed out again because we need to set these axes down here right before we plot the graph and now we see it zoomed in again. When I say we're plotting a by b it means we're coordinating these two values and so our first point is 0 0 so that starts off here and then we have our next point which is negative 100 so that's gonna be negative 100 here and then 3 so we see that there and then we have 25 and 7 and so we go 25 here we go up to 7 that's how it's plotted because we do a by b and so a we get 67 so we go to 67 over here and then it is at height 3 so we see that at height 3 and then we have negative 3 2 3 so that's why we go all the way back here and we see it's at that height 9. Now let's say I wanted to distort the labels of these like x ticks and so I wanted it to say hello kind of distorted here on the bottom. The way we can do that is with plt.xticks and inside of this we're gonna have the ticks we want to replace and so that's negative 40 negative 20 0 20 40 and then we're gonna put what we want to replace them with and so we have H E and we're spelling out hello. We can do shift enter and as you can see we have H E L L O and we have manipulated the graph in another way. We could also make this graph red by going color equals red inside of our plot call. We'll do that we'll hit enter and we see the graph is red now. Alright so we know about these line graphs. What about a different type of graph? What about a different way we want to visualize this data? Well we can use a histogram. We can go plt.hist and we'll put the a data in this case and we see all of this different data and so we have two zeros inside of the array. We have a negative 100 a 50 and a negative 300. Here if we go back to what is in our a array we have a variety of values. We have 0 and 25 which are kind of close to 0. We have an outlier of negative 3 2 3. We have negative 167. If we look at this they're not exactly on the 0 line or on the negative 300 line but you can kind of get a sense of how many of each piece of data we have. So we have two that are kind of near 0. We have one that's kind of near 50 so this 6 67 and then we have one that's kind of near a negative 100 and one that's near negative 3 2 3 and so negative 100 is exactly on the dot but most of the data is an estimate. We could also add another value here so say we do X and Y. Now we have two histograms that are right next to each other and we can compare them. So we see all of the X values are in blue and they are positive and all of the Y values are on that negative track and so they're shown over here. So this is a different type of distribution versus our X by Y example. Alright so those are the basics of Matplotlib. Thank you so much for watching and happy coding.
Generate a brief summary highlighting the main points of the transcript.
GenerateGenerate a concise and relevant title for the transcript based on the main themes and content discussed.
GenerateIdentify and highlight the key words or phrases most relevant to the content of the transcript.
GenerateAnalyze the emotional tone of the transcript to determine whether the sentiment is positive, negative, or neutral.
GenerateCreate interactive quizzes based on the content of the transcript to test comprehension or engage users.
GenerateWe’re Ready to Help
Call or Book a Meeting Now