1 00:00:00,060 --> 00:00:05,070 Hello, guys, and welcome back to the class of our course about the complete introduction to the science 2 00:00:05,070 --> 00:00:06,180 with Python. 3 00:00:06,690 --> 00:00:13,950 So in this class, we are still going to talk about matplotlib and some other things that we can do 4 00:00:13,950 --> 00:00:16,920 with this amazing add on to Python. 5 00:00:17,790 --> 00:00:23,490 So basically what we are going to learn today is how to create a certain type of graph. 6 00:00:23,520 --> 00:00:27,990 So basically, this is something that matplotlib can help you out with. 7 00:00:28,020 --> 00:00:29,810 So basically it's used for a visualization. 8 00:00:30,090 --> 00:00:34,120 So we will learn how to visualize our data with a bar graph. 9 00:00:34,140 --> 00:00:39,240 So basically how to create a bar graph, you'll see it's pretty simple and it works pretty much the 10 00:00:39,240 --> 00:00:41,550 same way as we saw it a little bit before. 11 00:00:42,360 --> 00:00:42,700 All right. 12 00:00:42,720 --> 00:00:49,050 So, as always, the first thing that we want to do right now is create our matplotlib. 13 00:00:49,050 --> 00:00:55,350 So we'll just write down, import my blood, Leyb Dot. 14 00:00:57,530 --> 00:01:01,520 So very important, try to not make a mistake by Plott. 15 00:01:04,140 --> 00:01:06,300 As VLT All right. 16 00:01:07,360 --> 00:01:12,790 So when it's all done, the next thing that we want to do is start start creating our craft. 17 00:01:13,000 --> 00:01:17,590 So this is the first part of the creation of a graph is creating the database. 18 00:01:17,600 --> 00:01:23,200 So in our case, what we will do right now is we'll create a graph with three functions inside of it. 19 00:01:23,230 --> 00:01:26,270 So basically, we'll have three X's in three ways. 20 00:01:27,130 --> 00:01:28,620 So pretty simple. 21 00:01:28,630 --> 00:01:32,110 What we'll do right now, we'll just give a name to each of our variables. 22 00:01:32,140 --> 00:01:37,750 So basically, we'll have X one, Y one, then X two. 23 00:01:39,560 --> 00:01:45,850 Why two and finally, we'll have X three as well as white. 24 00:01:47,150 --> 00:01:52,010 All right, so when everything is done, we'll just give certain values to our exes. 25 00:01:52,170 --> 00:01:59,120 So in the first case, we'll have X one, which would be, let's say two for six and Y one would be 26 00:01:59,600 --> 00:02:02,490 in this case, let's say three, six, nine. 27 00:02:03,170 --> 00:02:05,150 So you don't have to do the exact same thing as me. 28 00:02:05,150 --> 00:02:13,280 The numbers that I'm using are just random numbers to be able to just create a graph so you can use 29 00:02:13,280 --> 00:02:14,720 the numbers that you guys want. 30 00:02:15,050 --> 00:02:15,830 It's up to you. 31 00:02:16,130 --> 00:02:23,420 So in this case, I'd say, why two would be five, 10, 15 and for extra, let's say it's going to 32 00:02:23,420 --> 00:02:26,270 be six, 12, 18. 33 00:02:27,590 --> 00:02:33,110 And while she is going to be 12, 24, 36. 34 00:02:33,470 --> 00:02:37,130 All right, so until now, we have a database that is pretty simple. 35 00:02:37,140 --> 00:02:39,010 So you can see we have three functions. 36 00:02:39,010 --> 00:02:41,300 So we have enough data for three functions. 37 00:02:41,300 --> 00:02:46,050 In our case, the next thing that we will do right now is putting everything together. 38 00:02:46,400 --> 00:02:52,550 So basically, we are going to use the bar function in this case, because our goal, our goal is to 39 00:02:52,550 --> 00:02:55,110 create a bar chart with a bar graph. 40 00:02:55,760 --> 00:02:57,050 So how exactly will do this? 41 00:02:57,080 --> 00:02:57,770 It's pretty simple. 42 00:02:57,770 --> 00:03:00,140 So we'll write down our DOT bar. 43 00:03:00,590 --> 00:03:01,630 So we start with this. 44 00:03:02,180 --> 00:03:08,520 Then the next thing that we need to enter is the arguments that will be used inside of our bar graph. 45 00:03:08,540 --> 00:03:12,330 So basically, what are the variables that will use? 46 00:03:12,350 --> 00:03:15,190 In this case, we'll use the list right here in the list right here. 47 00:03:15,650 --> 00:03:20,090 So we'll use X one as well as Y one this. 48 00:03:20,180 --> 00:03:22,730 So this is for our first bar. 49 00:03:23,820 --> 00:03:26,300 We'll do the exact same thing for the other ones. 50 00:03:26,420 --> 00:03:29,930 So basically we have extra Y2 extra to watch. 51 00:03:30,680 --> 00:03:32,690 So then you can just change the names. 52 00:03:33,850 --> 00:03:38,060 And finally, XStream as well as White three. 53 00:03:38,960 --> 00:03:39,290 All right. 54 00:03:39,300 --> 00:03:42,680 So right now we have everything that we need to be able to create our graph. 55 00:03:42,950 --> 00:03:50,900 So the last thing that is left to do right now will be to add a title as well as a title for our access. 56 00:03:51,290 --> 00:03:52,240 So we'll write it down. 57 00:03:52,250 --> 00:03:56,490 So Kielty that title, this is the first step. 58 00:03:56,900 --> 00:03:58,780 So give a title to our graph. 59 00:03:58,790 --> 00:04:02,130 Let's call it test graph one. 60 00:04:02,720 --> 00:04:09,260 So this would be our graph title and then plot that X label. 61 00:04:10,830 --> 00:04:22,950 So in this case, let's call it test X name, and the next thing and the exact same thing will do for 62 00:04:22,950 --> 00:04:25,500 our Y y axis. 63 00:04:25,830 --> 00:04:25,950 So. 64 00:04:26,120 --> 00:04:29,130 All right, already done that Y label. 65 00:04:30,780 --> 00:04:37,170 And for our y axis will write the exact same DNA test y name. 66 00:04:37,890 --> 00:04:38,220 All right. 67 00:04:38,230 --> 00:04:40,890 So right now we have our exes and we have our weisse. 68 00:04:41,460 --> 00:04:43,170 So right now, everything is amazing. 69 00:04:43,180 --> 00:04:47,060 We can run our our a graph and see what it looks like. 70 00:04:47,340 --> 00:04:49,470 So very important to make up for mistakes. 71 00:04:49,470 --> 00:04:53,820 So especially for the little mistakes right here, because if you don't do it, you can have an error 72 00:04:53,820 --> 00:04:54,220 message. 73 00:04:54,600 --> 00:05:00,630 So finally, to run, everything will just write down Kielty show we open and close parentheses and 74 00:05:00,630 --> 00:05:01,590 we can run everything. 75 00:05:02,320 --> 00:05:07,080 So as you can see, we have our graph right here which shows us how everything works. 76 00:05:07,080 --> 00:05:08,800 And as you can see, it's pretty cool. 77 00:05:09,180 --> 00:05:11,660 So basically, we have our right there. 78 00:05:11,670 --> 00:05:15,580 We have our X1 x2 as well as Extra. 79 00:05:15,630 --> 00:05:18,940 So everything is inside of this graph and it's pretty nice. 80 00:05:19,830 --> 00:05:20,220 All right. 81 00:05:20,230 --> 00:05:24,510 So another thing that we can do right now is change the style of our graph. 82 00:05:24,960 --> 00:05:31,290 So basically, if we want to change the style of our graph, it's like always so we will need to import. 83 00:05:31,450 --> 00:05:35,500 In this case, we will import the style stuff package. 84 00:05:35,520 --> 00:05:37,430 So how exactly would this it's pretty simple. 85 00:05:37,440 --> 00:05:41,370 So we'll just write down the import style. 86 00:05:41,380 --> 00:05:43,500 So we need to import stuff from matplotlib. 87 00:05:44,130 --> 00:05:50,790 So done from Matt Leyb import style. 88 00:05:53,910 --> 00:05:58,770 And what we can do right now is we can change the scale of our graph, so it's pretty simple. 89 00:05:59,400 --> 00:06:01,840 We'll try it out, we'll just write down style use. 90 00:06:05,010 --> 00:06:06,240 So is the right here. 91 00:06:06,240 --> 00:06:12,720 I'm changing the style of my graph and let's say we want to use the in each style, so we'll call each. 92 00:06:13,980 --> 00:06:17,090 So this is a style type that exists so we can run everything. 93 00:06:17,820 --> 00:06:20,670 And as you can see, the style of our graph just changed. 94 00:06:20,690 --> 00:06:21,670 So it's a bit different. 95 00:06:21,690 --> 00:06:22,530 So everything works. 96 00:06:22,530 --> 00:06:29,550 We have the title of our graph here, the title of each axis, and finally the style of our graph that 97 00:06:29,550 --> 00:06:30,300 just changed. 98 00:06:30,660 --> 00:06:35,640 So if I'm making a quick interpretation of the code, so basically the first part right here is where 99 00:06:35,640 --> 00:06:39,050 we imported all the packages, as well as a sub package that we needed. 100 00:06:39,750 --> 00:06:43,830 The first part right here is the style that we want to use for our chart here. 101 00:06:43,830 --> 00:06:44,970 We have our database. 102 00:06:45,420 --> 00:06:47,500 So our database is right here. 103 00:06:47,790 --> 00:06:49,780 Here we have everything that we put together. 104 00:06:49,800 --> 00:06:53,700 So basically, we're creating the first function, the second one, as well as a third function right 105 00:06:53,700 --> 00:06:56,130 here with the use of our database. 106 00:06:56,910 --> 00:07:03,510 And finally, right here, we are giving names to our chart as well as to our axis. 107 00:07:03,540 --> 00:07:05,490 So basically the X and the Y axis. 108 00:07:05,740 --> 00:07:12,960 So I hope you guys understand how to create a well, this type of graph, which is a bar graph, and 109 00:07:13,290 --> 00:07:15,490 I hope that you will be able to use it in the future. 110 00:07:15,630 --> 00:07:16,210 So that's it for us. 111 00:07:16,240 --> 00:07:16,700 Thanks, guys. 112 00:07:16,710 --> 00:07:18,840 And see our next class.