1 00:00:00,300 --> 00:00:05,280 Hello, guys, and welcome back to our class of our course about the complete introduction to the science 2 00:00:05,280 --> 00:00:12,150 with the use of Python in this class, we are still talking about matplotlib and we are going to learn 3 00:00:12,150 --> 00:00:15,040 how to create another type of chart. 4 00:00:15,070 --> 00:00:22,140 So basically we are going to create another type of graph chart and that the one will be the big picture. 5 00:00:22,170 --> 00:00:29,310 So basically we are going to create a PI that will give a piece for each element that will have inside 6 00:00:29,310 --> 00:00:30,120 of our chart. 7 00:00:30,780 --> 00:00:32,760 So you'll see it's pretty simple to make. 8 00:00:32,760 --> 00:00:34,390 It's not that hard, but it's a bit different. 9 00:00:35,160 --> 00:00:40,800 So the first part of the course we are going to import matplotlib as we always do, then we are going 10 00:00:40,800 --> 00:00:42,740 to create arguments that we are going to use. 11 00:00:43,350 --> 00:00:47,190 We will have our arguments will simply create the function. 12 00:00:47,550 --> 00:00:49,840 So we'll use the PI function in this case. 13 00:00:50,250 --> 00:00:56,450 Finally, we'll give a title to our chart and show everything to to visualize that. 14 00:00:56,850 --> 00:01:01,020 And by the end, we'll also play with the style of this graph. 15 00:01:01,260 --> 00:01:02,070 So let's start. 16 00:01:02,890 --> 00:01:08,100 So I said the first thing that we will do is we will import matplotlib. 17 00:01:08,100 --> 00:01:09,840 So that block. 18 00:01:11,600 --> 00:01:16,640 That dog fight a lot, so when everything is imported, 19 00:01:20,030 --> 00:01:21,380 so everything is important. 20 00:01:21,950 --> 00:01:27,850 The second thing that we'll do is that we are going to work with the arguments that we will. 21 00:01:28,400 --> 00:01:34,430 So basically, for the purpose of discourse, what I can what I prepared is pretty simple. 22 00:01:34,440 --> 00:01:36,850 We are going to work with a basic example. 23 00:01:37,250 --> 00:01:44,150 So we'll have food that will be sold and basically will calculate the number of sales and the food that 24 00:01:44,150 --> 00:01:44,810 has been sold. 25 00:01:44,810 --> 00:01:48,410 And we'll give each type of food a certain color. 26 00:01:49,430 --> 00:01:50,000 So let's do it. 27 00:01:50,030 --> 00:01:53,290 So basically, we'll start with writing down the foods that we have. 28 00:01:53,780 --> 00:01:57,230 So we have our food right here and what exactly we have like food. 29 00:01:57,230 --> 00:01:59,260 So we will have, let's say, pizza. 30 00:02:02,300 --> 00:02:03,860 We will have ice cream. 31 00:02:06,900 --> 00:02:13,380 And finally, we will have, let's say, burgers, so as you can see, pretty simple, so we have three 32 00:02:13,380 --> 00:02:14,030 types of food. 33 00:02:14,490 --> 00:02:17,520 The same thing that we'll need is the sales for each one. 34 00:02:17,550 --> 00:02:24,930 So basically, let's say we have sold out on know let's say we have sold 20 pizzas. 35 00:02:30,110 --> 00:02:32,450 We have sold what else? 36 00:02:33,580 --> 00:02:38,320 We have sold 10 ice creams and we have sold 30 burgers. 37 00:02:40,110 --> 00:02:43,720 All right, and finally, the last thing that we will need is the colors. 38 00:02:43,740 --> 00:02:49,920 So basically what color, what color will be used for each of those things? 39 00:02:51,060 --> 00:02:52,750 So in this case, pretty simple for pizza. 40 00:02:52,810 --> 00:02:54,540 Let's say it's going to be red. 41 00:03:00,310 --> 00:03:07,060 For ice cream, let's say it's going to be blue and finally for burgers, let's say it's going to be 42 00:03:07,060 --> 00:03:07,570 yellow. 43 00:03:08,620 --> 00:03:08,890 All right. 44 00:03:08,890 --> 00:03:11,730 So we have everything that we need for our pie chart. 45 00:03:11,740 --> 00:03:14,750 So basically, we have our types of food that we will use. 46 00:03:15,070 --> 00:03:18,230 We have the sales that have been made for each type of food. 47 00:03:18,250 --> 00:03:22,490 And finally, the color for each type of food that we have. 48 00:03:23,080 --> 00:03:24,900 So let's write down the functions. 49 00:03:24,940 --> 00:03:25,770 It's pretty simple. 50 00:03:25,780 --> 00:03:29,870 It's going to be pretty that by since we're that's a pie chart. 51 00:03:31,090 --> 00:03:36,070 So the first part of it will be the what are the numbers that we have sold. 52 00:03:36,100 --> 00:03:40,450 So basically, this is the first part and the numbers are in the variable sales. 53 00:03:41,380 --> 00:03:43,530 So we'll just write down sales right here. 54 00:03:44,800 --> 00:03:48,910 Then the second element of the variable will be the colors or the type of food. 55 00:03:48,920 --> 00:03:51,960 So basically in this case, we are going to use the type of food. 56 00:03:52,840 --> 00:03:53,930 So it's called labels. 57 00:03:53,940 --> 00:03:56,210 So what are the labels that we are? 58 00:03:56,920 --> 00:03:58,030 What are the labels? 59 00:04:00,900 --> 00:04:02,440 That's the one right here. 60 00:04:03,310 --> 00:04:03,580 Right. 61 00:04:04,000 --> 00:04:08,830 So what exactly are the labels that we are going to give to each part of our picture? 62 00:04:08,860 --> 00:04:12,970 So in this case, the labels will be pizza, ice cream, as well as burgers. 63 00:04:13,900 --> 00:04:17,790 And the labels are inside of the variable food food. 64 00:04:18,790 --> 00:04:22,940 Finally, the last variable that we will need will be the color viable. 65 00:04:23,260 --> 00:04:27,240 So in this case, what each label will have like a color. 66 00:04:27,250 --> 00:04:29,140 So what color will have? 67 00:04:29,470 --> 00:04:31,360 So in this case, it's pretty simple. 68 00:04:31,540 --> 00:04:32,650 It's called colors. 69 00:04:33,640 --> 00:04:41,050 And the label, the color is a variable right here will be linked with the variable color, will just 70 00:04:41,050 --> 00:04:42,040 write down color. 71 00:04:42,760 --> 00:04:43,090 All right. 72 00:04:43,100 --> 00:04:46,870 So we have everything that we need and now it's time to run that well. 73 00:04:46,900 --> 00:04:49,390 Now it's time to give it title to our church. 74 00:04:49,390 --> 00:04:51,310 So let's just give it a title. 75 00:04:54,220 --> 00:04:58,270 So let's name an example, for just example. 76 00:05:03,070 --> 00:05:08,980 All right, so right now we have the title of our chart listing that we have left to do is simply see 77 00:05:08,980 --> 00:05:10,090 what it all looks like. 78 00:05:10,100 --> 00:05:12,220 So we will run everything. 79 00:05:12,310 --> 00:05:14,400 I just ran without that show. 80 00:05:15,670 --> 00:05:18,590 And as you can see, this is our pie chart that we have. 81 00:05:18,610 --> 00:05:23,980 So if we compare what we have right here with answers, so basically we have our title that is example, 82 00:05:23,980 --> 00:05:24,280 food. 83 00:05:24,610 --> 00:05:29,950 We have pizza, which is the first one, and has twenty sales, which is the second biggest one. 84 00:05:30,220 --> 00:05:32,890 We have burgers, which is the half of the pie. 85 00:05:32,920 --> 00:05:34,390 So in this case, 30 sales. 86 00:05:34,690 --> 00:05:39,310 And finally, as ice cream only has 10 sales is the lowest one right there. 87 00:05:39,730 --> 00:05:40,660 So everything makes sense. 88 00:05:41,410 --> 00:05:41,730 All right. 89 00:05:41,740 --> 00:05:44,980 So right now that everything works, we can play with the style. 90 00:05:45,010 --> 00:05:46,570 So once again, this is what we will do. 91 00:05:46,900 --> 00:05:49,320 So we'll import the sub package styles. 92 00:05:49,330 --> 00:05:55,030 So just write down from my blood glib import. 93 00:05:57,130 --> 00:06:04,990 Style and what we'll do right now, we'll just add a style to our charts, we'll just write down style 94 00:06:05,230 --> 00:06:09,700 use and we can choose the type of style that we want for this class. 95 00:06:09,700 --> 00:06:10,930 We can use classic. 96 00:06:11,320 --> 00:06:14,170 This is one type of one style that exists. 97 00:06:14,590 --> 00:06:17,410 So if everything as you can see, it became a bit different. 98 00:06:17,410 --> 00:06:18,670 The background became great. 99 00:06:18,680 --> 00:06:21,550 So basically, this is another style that can be used. 100 00:06:22,030 --> 00:06:27,340 So if you guys want to change, for example, the numbers right here put let's say 15 instead of 10, 101 00:06:27,340 --> 00:06:32,950 you can do it if you want to change the color instead of blue, putting green, for example, you can 102 00:06:32,950 --> 00:06:33,780 do it as well. 103 00:06:33,790 --> 00:06:38,170 And if you run the app, you'll see it's going to automatically adapt. 104 00:06:39,100 --> 00:06:40,320 So you can see it's pretty simple. 105 00:06:40,330 --> 00:06:43,390 And this is an amazing visual visual, too. 106 00:06:43,720 --> 00:06:51,700 So basically it allows you to see visually your data and be able to get the answers that you need pretty 107 00:06:52,170 --> 00:06:52,510 easy. 108 00:06:52,930 --> 00:06:56,200 So that's a first class guys and all our next class.