1 00:00:00,530 --> 00:00:01,520 Welcome back. 2 00:00:01,520 --> 00:00:05,820 Hopefully you've created your own graph here and of a plot or figure. 3 00:00:05,840 --> 00:00:06,250 See. 4 00:00:06,290 --> 00:00:09,680 Again I'm mispronouncing all these different words. 5 00:00:09,680 --> 00:00:14,290 Hopefully your prices aren't cheaper because they're not but a game is very competitive these days. 6 00:00:14,360 --> 00:00:19,340 So the last video we finished off on bar graphs there is actually a horizontal bar graph. 7 00:00:19,340 --> 00:00:20,790 You may have seen this before. 8 00:00:20,810 --> 00:00:31,970 So if we go fig X equals plot dot subplots and we go axe DOB bar Hage for horizontal we're going to 9 00:00:31,970 --> 00:00:34,410 pass it just the exact same thing as above now. 10 00:00:34,440 --> 00:00:42,110 But our prices dot ks and nut but because we've got our saved dictionary up there. 11 00:00:42,110 --> 00:00:47,500 Yours might be a different name dot values. 12 00:00:47,520 --> 00:00:49,220 Oh what's happened here. 13 00:00:51,520 --> 00:00:54,070 Uncatchable type decays. 14 00:00:54,080 --> 00:00:55,130 Mm hmm. 15 00:00:55,180 --> 00:01:01,480 I actually did look this one up in this case for the bar horizontal we have to turn our values here 16 00:01:01,900 --> 00:01:03,520 into a list. 17 00:01:03,750 --> 00:01:09,730 Now had I find that well I did our search method I looked it up pre banked it I had to make sure that 18 00:01:09,730 --> 00:01:14,950 I was getting things right for this one since we messed up in the last lecture but that's okay so I 19 00:01:14,950 --> 00:01:20,950 go there we've got a horizontal bar same information just presented horizontally now. 20 00:01:21,020 --> 00:01:22,300 Which one should you use. 21 00:01:22,400 --> 00:01:24,050 It's more of a personal preference here. 22 00:01:24,200 --> 00:01:25,070 I like this one. 23 00:01:25,070 --> 00:01:26,060 It's vertical. 24 00:01:26,060 --> 00:01:28,040 Sometimes you'll want a horizontal bar. 25 00:01:28,040 --> 00:01:30,380 There are other plots that look better on a horizontal. 26 00:01:30,440 --> 00:01:33,440 We'll have a look at some of those in potentially a future video. 27 00:01:33,480 --> 00:01:35,080 Now let's check out. 28 00:01:35,180 --> 00:01:36,320 What have we done so far. 29 00:01:37,070 --> 00:01:42,350 We've done line we've done scatter we Dunbar let's do his diagrams what's a histogram. 30 00:01:42,350 --> 00:01:43,800 Well let's see I first remember. 31 00:01:43,940 --> 00:01:49,400 If in doubt run the code I'll make some data we'll go. 32 00:01:49,400 --> 00:01:58,640 X equals and paid a random dot Rand in and we want a thousand of what is Rand end to shift tab. 33 00:01:58,640 --> 00:02:03,580 Return a sample or samples from the standard normal distribution. 34 00:02:03,590 --> 00:02:05,570 What is this standard normal distribution. 35 00:02:05,690 --> 00:02:06,750 Let's have a look. 36 00:02:06,890 --> 00:02:08,630 Normal Distribution 37 00:02:13,830 --> 00:02:14,660 go here. 38 00:02:15,310 --> 00:02:16,150 Okay. 39 00:02:16,350 --> 00:02:22,920 In probability fearing the normal or Gaussian distribution is very common continuous probability distribution. 40 00:02:22,940 --> 00:02:30,920 Well that was a bit of a mouthful but what you really need to know is a normal distribution are these 41 00:02:30,920 --> 00:02:32,050 curves here. 42 00:02:32,110 --> 00:02:37,760 So in the middle here this is the main and the distance between the main and here is a variance. 43 00:02:37,760 --> 00:02:43,100 And so whenever someone refers to a normal distribution they're referring to one of these kind of like 44 00:02:43,100 --> 00:02:47,730 symmetrical curves and they can appear anywhere on the x axis like this. 45 00:02:47,750 --> 00:02:50,630 That's what you need to know about a normal distribution. 46 00:02:50,630 --> 00:02:57,710 So if we go in here this is going to make some a thousand random samples that would fit within this 47 00:02:57,710 --> 00:02:58,490 curve. 48 00:02:58,640 --> 00:03:02,200 But if in doubt run the code let's actually see this in action. 49 00:03:02,210 --> 00:03:09,380 Fig X equals because remember every time we want a new plot we create a new plot subplots X dot hist 50 00:03:09,860 --> 00:03:12,430 X little semicolon at the end. 51 00:03:12,470 --> 00:03:19,970 So what we've done here is we're doing a histogram but oftentimes you'll see it shortened to hist so 52 00:03:20,040 --> 00:03:22,850 you see hist probably referring to histogram. 53 00:03:23,020 --> 00:03:24,830 So if we do that huh. 54 00:03:24,840 --> 00:03:26,220 There we go. 55 00:03:26,220 --> 00:03:32,610 We've got a bumpy curve it's not as smooth as this one but you can kind of see it's got the same shape. 56 00:03:32,610 --> 00:03:33,640 That's what we're after. 57 00:03:33,660 --> 00:03:35,580 Just that same shape. 58 00:03:35,580 --> 00:03:36,960 Beautiful. 59 00:03:36,960 --> 00:03:37,540 Okay. 60 00:03:37,680 --> 00:03:39,840 Now we've covered histogram is now. 61 00:03:39,900 --> 00:03:44,370 What if you wanted to get multiple plots happening at the same time we've referred to this before as 62 00:03:44,370 --> 00:03:45,880 subplots. 63 00:03:45,990 --> 00:03:50,470 Well the beautiful thing is we can make them with the command we've been using. 64 00:03:50,490 --> 00:04:00,780 Now again there's two options for actually histogram because you want to make this a bit more communicated 65 00:04:01,650 --> 00:04:02,510 and plot it. 66 00:04:02,520 --> 00:04:03,060 There we go. 67 00:04:03,990 --> 00:04:05,610 We're in the habit of being communicative. 68 00:04:05,690 --> 00:04:10,860 So you're gonna finish off that cell before we suddenly one two options for subplots. 69 00:04:10,950 --> 00:04:19,270 Let's do that make a little heading and then we'll go subplot option one. 70 00:04:19,270 --> 00:04:20,410 Wonderful. 71 00:04:20,410 --> 00:04:20,640 Okay. 72 00:04:20,650 --> 00:04:22,110 We're going to create Fig. 73 00:04:22,240 --> 00:04:24,480 Now this is gonna look a bit different to what we've been doing. 74 00:04:24,480 --> 00:04:28,570 AX 1 ax 2 new light wall what's going on here Daniel. 75 00:04:28,570 --> 00:04:29,810 But don't worry. 76 00:04:30,010 --> 00:04:34,930 Follow along and we'll explain in a second because remember when the habit of just seeing what happens 77 00:04:34,930 --> 00:04:38,720 with the code and Rosie goes to hold on. 78 00:04:38,830 --> 00:04:41,190 We never passed a keyword argument to this. 79 00:04:41,210 --> 00:04:44,310 Now we're gonna pass three living dangerously I told you. 80 00:04:44,740 --> 00:04:49,420 Big size equals ten five. 81 00:04:49,570 --> 00:04:51,940 Well my five key is a bit sticky you know. 82 00:04:51,940 --> 00:04:54,480 So if we look what is this actually doing. 83 00:04:54,670 --> 00:04:55,150 Let's run it 84 00:04:58,550 --> 00:05:06,540 look at that now can we infer what's happening here without even looking at the doctoring so we've got 85 00:05:06,540 --> 00:05:15,140 fig comma and then a tuple which is of tuples of x 1 x 2 acts 3 X 4. 86 00:05:15,630 --> 00:05:20,610 So can you guess what's happening here and we've got some keyword arguments and rows equals two and 87 00:05:20,610 --> 00:05:24,910 Coles equals two fig size equals 10 five. 88 00:05:25,470 --> 00:05:26,680 What do you think's happening. 89 00:05:26,790 --> 00:05:30,430 And rows equals to two rows two columns. 90 00:05:30,660 --> 00:05:35,670 I've got X one maybe x two x three x four. 91 00:05:35,850 --> 00:05:38,450 I think that would be pretty spot on if that's what you guessed. 92 00:05:38,580 --> 00:05:39,560 Said I guessed. 93 00:05:39,600 --> 00:05:41,250 So here we go. 94 00:05:41,250 --> 00:05:44,690 Let's read create a figure instead of subplots this utility. 95 00:05:44,730 --> 00:05:45,980 Yeah we've read that before. 96 00:05:46,470 --> 00:05:51,030 And rows number of rows columns of the subplot grid beautiful. 97 00:05:51,030 --> 00:05:54,600 Now let's see how would we get data on here. 98 00:05:54,600 --> 00:06:00,540 So let's let's do this plot to each different axis. 99 00:06:00,540 --> 00:06:04,480 Let's say this inaction asks one dot plot. 100 00:06:04,890 --> 00:06:08,960 Let's go to X you've got some X data I think that'll probably do. 101 00:06:08,970 --> 00:06:15,240 Let's see what happens when we do plot it bam straight line. 102 00:06:15,270 --> 00:06:15,960 Wonderful. 103 00:06:15,960 --> 00:06:19,340 We can do that okay. 104 00:06:19,430 --> 00:06:22,150 So yeah x 1 is this top left 1. 105 00:06:22,340 --> 00:06:22,660 Okay. 106 00:06:22,660 --> 00:06:24,920 That's that makes sense because it comes first. 107 00:06:24,950 --> 00:06:27,410 Can you guess which one is x 2. 108 00:06:27,410 --> 00:06:29,380 Well let's see and find out empty. 109 00:06:29,390 --> 00:06:31,910 Let's make some some more random data. 110 00:06:31,910 --> 00:06:40,560 Random random 10 and we'll do random random again 10 and semicolon huh. 111 00:06:40,590 --> 00:06:41,030 Okay. 112 00:06:41,040 --> 00:06:43,080 And see we've tried a little scatter here. 113 00:06:43,080 --> 00:06:46,130 So that's x 2 wonderful x ray. 114 00:06:46,140 --> 00:06:47,630 Let's do a bar on this one. 115 00:06:47,650 --> 00:06:51,090 We're gonna start mixing this up you know not but can I do tab complete. 116 00:06:51,080 --> 00:06:51,980 Not better prices. 117 00:06:52,010 --> 00:06:53,110 Yes I can. 118 00:06:53,160 --> 00:07:00,090 Doug K's not but we want the values on this one dollar values. 119 00:07:00,090 --> 00:07:01,180 Wonderful. 120 00:07:01,230 --> 00:07:02,930 Let's see what happens. 121 00:07:02,940 --> 00:07:05,820 Beautiful we're starting to feel an alpha subplot here. 122 00:07:05,820 --> 00:07:13,380 This is wonderful access for we want haste and then we want and paid a random grand and normal distribution 123 00:07:13,380 --> 00:07:17,700 we take that out before there we go. 124 00:07:17,760 --> 00:07:21,550 Now we have a subplot with four different subplots. 125 00:07:21,570 --> 00:07:23,900 Now again this is just some dummy data except for this. 126 00:07:23,900 --> 00:07:25,290 This is real stuff right here. 127 00:07:25,290 --> 00:07:31,020 This is Dan's arm about a store and now you can add some titles to these actresses much like we've done 128 00:07:31,020 --> 00:07:34,090 up here with this set command here. 129 00:07:34,980 --> 00:07:37,170 But this is just to exemplify one way. 130 00:07:37,200 --> 00:07:42,510 Option one would do option two in a moment maybe in the next video of how you can get more information 131 00:07:42,600 --> 00:07:43,860 on the one figure. 132 00:07:43,860 --> 00:07:50,000 So if we look back to our anatomy here it's still a big figure. 133 00:07:50,030 --> 00:07:53,840 This blue square if we converted this blue square it's going to follow around this. 134 00:07:53,960 --> 00:07:58,800 But now we've got axes zero axes one axes three axes four. 135 00:07:59,000 --> 00:08:03,010 But it's actually actually zero one two three. 136 00:08:03,050 --> 00:08:04,850 But we've named them differently. 137 00:08:04,850 --> 00:08:10,530 In reality we should have probably zero indexes but I've just gone one two three four. 138 00:08:10,560 --> 00:08:15,440 Now you're starting to see if you wanted to get more information just one image rather than having four 139 00:08:15,440 --> 00:08:19,310 different figures you can say you can do that with subplots. 140 00:08:19,340 --> 00:08:27,950 The reason why we've been using this command is that you can create single plots or multiple plots with 141 00:08:27,950 --> 00:08:28,760 the same command. 142 00:08:28,760 --> 00:08:34,160 That's that flexibility we were talking about of the object oriented API for map plot lib. 143 00:08:34,220 --> 00:08:39,410 So this is option one for the video I guess too long will pause it there and we'll have a look at option 144 00:08:39,410 --> 00:08:40,280 2 and the next one.