1 00:00:00,560 --> 00:00:01,680 All righty. 2 00:00:01,680 --> 00:00:05,400 So we've seen create quite a complex plot. 3 00:00:05,610 --> 00:00:12,810 But in terms of customization we've kind of glazed over these set parameters and title and X label and 4 00:00:12,810 --> 00:00:13,950 Y label or not. 5 00:00:14,970 --> 00:00:19,430 So what we're gonna do now is look at customization of plots a little bit more in-depth. 6 00:00:19,560 --> 00:00:27,480 And by the end of this video perhaps the next video we're going to replicate or transform this plot 7 00:00:28,020 --> 00:00:31,080 into something which looks exactly like the one we've got here. 8 00:00:31,080 --> 00:00:36,060 So the data's still the same but you can kind of see that there's a different style in terms of color 9 00:00:36,420 --> 00:00:40,800 line and just the tax is a little bit different the font. 10 00:00:40,950 --> 00:00:42,640 The axes are a little bit different. 11 00:00:42,750 --> 00:00:48,550 So let's get into it a is what we're going to do first is have a look at some different styles of matte 12 00:00:48,550 --> 00:00:49,270 plot lib. 13 00:00:49,630 --> 00:00:57,730 So the beautiful thing about matte plot lib is that again one of its other customizable parameters is 14 00:00:57,850 --> 00:00:59,900 this style of plot that you're using. 15 00:00:59,920 --> 00:01:05,650 So if the default one which is what we're kind of using now doesn't quite look how you want it to look. 16 00:01:05,740 --> 00:01:13,520 You can try other different styles so let's go down here and make a little section customizing matte 17 00:01:13,530 --> 00:01:18,960 plot lib plots and getting stylish. 18 00:01:18,990 --> 00:01:20,640 Yeah that's what we're gonna do. 19 00:01:20,640 --> 00:01:27,840 We in stylish see the different styles available. 20 00:01:28,020 --> 00:01:35,040 Now what this is going to do is if we call BLT dot style dot available it's going to tell us what kind 21 00:01:35,040 --> 00:01:41,910 of styles map plot Lee has available to us right now by default by just importing that plot layer right 22 00:01:41,910 --> 00:01:42,820 at the top. 23 00:01:42,870 --> 00:01:49,720 We're using the default style but as you can see there's about 20 other styles that you can use. 24 00:01:49,800 --> 00:01:55,200 So let's try out a few of these but first we remind ourselves of what the default style looks like. 25 00:01:55,200 --> 00:02:02,070 That way we can compare and see which one we like best because I've tried a few of these and I kind 26 00:02:02,070 --> 00:02:03,780 of know which ones I like. 27 00:02:03,780 --> 00:02:09,590 But again it'll come down to personal preference of what kind of style you want to use so this is the 28 00:02:09,590 --> 00:02:10,670 default style. 29 00:02:10,790 --> 00:02:14,090 Plotting the car sales data frame that we've seen a few times now. 30 00:02:14,390 --> 00:02:18,900 So car sales don't head the same car sales. 31 00:02:18,930 --> 00:02:23,960 Well car sales data frame report the plus column got a beautiful line graph. 32 00:02:23,980 --> 00:02:25,950 Now that's that's pretty good on its own. 33 00:02:26,030 --> 00:02:27,110 So let's have a look. 34 00:02:27,200 --> 00:02:36,700 Maybe we want to use peyote dot style to use and I'm gonna choose the seaborne white grid. 35 00:02:36,780 --> 00:02:44,750 Let's see what that looks like we'll type that in seaborne White red. 36 00:02:44,790 --> 00:02:46,530 Wonderful. 37 00:02:46,590 --> 00:02:50,660 So that's going to update Matt Gottlieb's style internally. 38 00:02:50,790 --> 00:02:54,550 So if we call the same plot that we did before. 39 00:02:54,660 --> 00:03:00,470 Price dot plot put a semicolon at the end. 40 00:03:00,480 --> 00:03:01,640 So it looks a bit different. 41 00:03:01,650 --> 00:03:04,110 Now we've got some grid lines here. 42 00:03:04,140 --> 00:03:11,840 We've got a little bit of a gap here maybe the Axis his limit is a bit higher for the y axis but generally 43 00:03:11,870 --> 00:03:14,500 quite the same as the default map plot lib style now. 44 00:03:14,790 --> 00:03:19,960 And you might think that the map bot lib default style is perfect for unis and that's okay. 45 00:03:19,970 --> 00:03:24,080 We've gone through these different styles right because I want you to understand just how customizable 46 00:03:24,110 --> 00:03:25,300 these plots are. 47 00:03:25,310 --> 00:03:28,730 Let's try another plot dot style dot use. 48 00:03:28,940 --> 00:03:31,970 And this time we might just use the default save on. 49 00:03:31,970 --> 00:03:39,130 So if we go up here Seabourn on its own now Seabourn is another plodding library that's built off map 50 00:03:39,130 --> 00:03:40,750 plot lib. 51 00:03:40,750 --> 00:03:44,650 And now we're going to a car sales price. 52 00:03:50,410 --> 00:03:51,420 Wonderful. 53 00:03:51,430 --> 00:03:53,670 So now kind of a little bit different. 54 00:03:54,560 --> 00:03:55,310 So this is what. 55 00:03:55,310 --> 00:03:55,520 Great. 56 00:03:55,540 --> 00:04:00,160 So we've got a white background that kind of makes sense but the default Seabourn style kind of has 57 00:04:00,160 --> 00:04:01,610 this gray background. 58 00:04:01,690 --> 00:04:07,910 But again we're still plotting the exact same data just mixing up the style mixing up the colors. 59 00:04:07,930 --> 00:04:11,000 Why don't we try another kind of plot. 60 00:04:11,050 --> 00:04:16,240 Where did car sales help launch now that the style is set to Seabourn. 61 00:04:16,270 --> 00:04:21,190 How about we check the odometer K M and then let's go. 62 00:04:21,190 --> 00:04:22,960 Domino versus price. 63 00:04:22,960 --> 00:04:25,360 We've seen this plot somewhere before. 64 00:04:25,360 --> 00:04:25,970 Kind. 65 00:04:25,980 --> 00:04:30,280 Eagles will make it a scatter plot. 66 00:04:30,290 --> 00:04:30,920 There we go. 67 00:04:30,990 --> 00:04:34,530 So a little bit different to the original scatter plot that we've seen before. 68 00:04:34,790 --> 00:04:36,730 This one maybe look a bit better to you. 69 00:04:36,730 --> 00:04:44,990 I personally prefer the Seabourn style so I might run this line of code when I start a new notebook. 70 00:04:45,020 --> 00:04:50,150 So run it right at the top under my map plot maybe imports just to make sure all my plots are in the 71 00:04:50,150 --> 00:04:53,690 Seabourn style so we'll save that there. 72 00:04:53,690 --> 00:04:58,970 That's not a good habit to get into is just hitting command or control s every so often with your notebooks 73 00:04:59,630 --> 00:05:06,140 and we might use one more plot just for good luck plot style this time we're going to use G.G. plot 74 00:05:06,650 --> 00:05:10,450 which is up here G.G. plot is a different kind of style. 75 00:05:11,420 --> 00:05:16,450 And so do the price graph again price. 76 00:05:16,690 --> 00:05:19,370 The plot. 77 00:05:19,380 --> 00:05:19,860 There you go. 78 00:05:19,860 --> 00:05:24,720 So now we got a bit of a different maybe a creamy Gray I don't know how you would describe that color 79 00:05:24,960 --> 00:05:31,620 but the line is definitely changed to red as you can see seaborne kind of comes with some axis titles 80 00:05:31,950 --> 00:05:36,210 by default whereas these don't have them. 81 00:05:36,270 --> 00:05:37,140 OK. 82 00:05:37,290 --> 00:05:39,240 Now these are some sweet looking plot. 83 00:05:39,780 --> 00:05:41,680 And now we're seeing that a change up the style. 84 00:05:41,700 --> 00:05:45,810 How about the titles the legend and the Axis scenes like this one doesn't have any. 85 00:05:45,900 --> 00:05:52,880 It just has numbers on both axes if a plot is worth a thousand words adding a few more can't hurt right. 86 00:05:53,070 --> 00:05:54,210 So let's do that. 87 00:05:54,210 --> 00:06:00,110 We'll go or create some dummy data create some data x equals. 88 00:06:00,120 --> 00:06:01,410 We've seen this before. 89 00:06:01,410 --> 00:06:08,810 Number pi Rand in we'll go 10 for there we go. 90 00:06:08,870 --> 00:06:09,990 We've got an array there. 91 00:06:10,010 --> 00:06:10,730 Wonderful. 92 00:06:10,850 --> 00:06:12,650 Now we'll put that into a data frame. 93 00:06:12,710 --> 00:06:18,080 We've created a data frame like this before but we're just going to practice practice practice reworking 94 00:06:18,260 --> 00:06:19,580 some of the things we've already done. 95 00:06:19,580 --> 00:06:22,840 That way they start to sink into memory a bit more. 96 00:06:23,250 --> 00:06:25,460 See these wonderful. 97 00:06:25,460 --> 00:06:27,130 Now this should give us a data frame. 98 00:06:28,040 --> 00:06:31,280 Four columns 10 rows of some random numbers. 99 00:06:31,280 --> 00:06:32,480 Beautiful. 100 00:06:32,570 --> 00:06:36,380 And now we're going to create a simple plot. 101 00:06:36,380 --> 00:06:41,070 Now this we're going to use a pipeline API because we want to just create a plot quickly. 102 00:06:41,270 --> 00:06:46,910 If you wanted to create something more in-depth like we've done here where is there you would probably 103 00:06:46,910 --> 00:06:49,820 use the object orientated API. 104 00:06:49,820 --> 00:06:55,700 But because we're doing some quick and dirty plots at the moment we'll just use the plot straight from 105 00:06:55,700 --> 00:07:02,000 the pan this data frame with the pie plot API so kind equals bar and then we going to look at the type 106 00:07:02,000 --> 00:07:04,400 of x beautiful. 107 00:07:05,250 --> 00:07:10,290 So this is a bar graph that we've built just off this data frame here we've got some negative and positive 108 00:07:10,290 --> 00:07:13,200 values different colors for the different columns. 109 00:07:13,200 --> 00:07:14,400 That all makes sense. 110 00:07:14,880 --> 00:07:21,930 And now we're going to customize our plot with this set method. 111 00:07:22,980 --> 00:07:24,380 So we've got X. 112 00:07:24,430 --> 00:07:27,640 We'll rewrite it X so we can see it all in one cell. 113 00:07:27,820 --> 00:07:31,540 After plot kind equals bar. 114 00:07:31,690 --> 00:07:32,500 Wonderful. 115 00:07:32,890 --> 00:07:37,720 And now we want to add some labels and a title. 116 00:07:37,810 --> 00:07:42,280 So we want X dot set and we've got title. 117 00:07:42,280 --> 00:07:49,300 So as you can probably guess this is gonna set the title random bar graph from data frame 118 00:07:51,740 --> 00:07:54,910 wonderful I've spelt graph terribly. 119 00:07:54,920 --> 00:07:56,130 That's right. 120 00:07:56,180 --> 00:07:56,750 There we go. 121 00:07:56,750 --> 00:08:00,180 And then within this set set has a few parameters here. 122 00:08:00,200 --> 00:08:04,430 So we go shift tab there we go shift keyword args. 123 00:08:04,430 --> 00:08:09,230 So this is probably another one you probably want to look into the documentation to start to figure 124 00:08:09,230 --> 00:08:12,750 out all the different kinds of customizations you can add to it. 125 00:08:12,830 --> 00:08:20,140 But we're just gonna go through the main ones which are Title X label and Y label deprived the bare 126 00:08:20,140 --> 00:08:23,890 minimum you'd want on any plot or figure that you create right. 127 00:08:23,980 --> 00:08:29,230 You want to know what's on the x axis and you want to know what's on the y axis rather than just having 128 00:08:29,230 --> 00:08:32,010 numbers in row number random number. 129 00:08:32,170 --> 00:08:37,990 Simple titles and then we'll make the legend visible. 130 00:08:38,020 --> 00:08:44,770 Now this one is kind of confusing because the legend already is visible but if it wasn't visible some 131 00:08:44,830 --> 00:08:47,470 plots do have a legend already built in. 132 00:08:47,590 --> 00:08:55,810 So you can use this X dot legend dot set it visible and then sets that visible to true which won't really 133 00:08:55,810 --> 00:08:57,660 change ours because it's already visible. 134 00:08:57,780 --> 00:08:58,990 But let's see what happens. 135 00:09:00,210 --> 00:09:01,140 What do we got here. 136 00:09:04,090 --> 00:09:06,780 Axis plot has no property title. 137 00:09:06,900 --> 00:09:09,530 Oh another typo. 138 00:09:09,590 --> 00:09:10,380 There we go. 139 00:09:11,290 --> 00:09:12,010 Wonderful. 140 00:09:12,010 --> 00:09:18,430 So now we've got the same exact same plot as up here but now we've just used a set method to add in 141 00:09:18,760 --> 00:09:22,820 an axis label on the Y and the X and a title. 142 00:09:22,850 --> 00:09:27,270 So that's starting to look a lot more communicative right there right. 143 00:09:27,490 --> 00:09:31,540 Now what if the style we're using doesn't quite suit the plot. 144 00:09:31,540 --> 00:09:33,190 We're trying to make. 145 00:09:33,280 --> 00:09:39,970 So that's what I'll probably look into the next video will change around the style within a set style. 146 00:09:39,970 --> 00:09:41,310 So that sounds a little confusing. 147 00:09:41,320 --> 00:09:46,780 Don't worry we'll go through it in the next video but in the meantime try out creating some of your 148 00:09:46,780 --> 00:09:51,310 own plots using plot style and use and pick one. 149 00:09:51,370 --> 00:09:56,020 Anyone from this list and you start to get a feel for what the different styles look like. 150 00:09:56,020 --> 00:10:03,070 My personal favorite is probably C bone or bond white greed seaborne generally just has some great styles 151 00:10:03,070 --> 00:10:04,590 down here. 152 00:10:04,630 --> 00:10:09,190 All right let's take a little break write some custom code and I'll see you shortly.