‫Welcome back.
‫Hopefully you've created your own graph here out of a plot or figure.
‫See, again, I'm mispronouncing all these different words.
‫Hopefully your prices aren't cheaper because they're not.
‫But a game is very competitive these days.
‫So the last video we finished off on bar graphs, there is actually a horizontal bar graph.
‫You may have seen this before.
‫So if we go fig ax equals plot subplots and we go X bar H for horizontal.
‫We're going to pass it the exact same thing as above, not bar prices dot k's and nut butter because
‫we've got our save dictionary up there.
‫Yours might be a different name.
‫Dot values.
‫Oh, what's happened here?
‫Uncatchable type decays.
‫Hmm.
‫I actually did look this one up.
‫In this case, for the bar horizontal, we have to turn our values here into a list.
‫Now, how do I find that?
‫Well, I did.
‫Now, search method.
‫I looked it up, I pre-baked it.
‫I had to make sure that I was getting things right for this one.
‫Since we messed up in the last lecture.
‫But that's okay.
‫So we go there.
‫We've got a horizontal bar.
‫Same information just presented horizontally.
‫Now which one should you use?
‫It's more of a personal preference here.
‫I like this one.
‫It's vertical.
‫Sometimes you'll want a horizontal bar.
‫There are other plots that look better on a horizontal.
‫We'll have a look at some of those in potentially a future video.
‫Well, let's check out what have we done so far?
‫We've done line, we've done scatter, we done bar.
‫Let's do histograms.
‫What's a histogram?
‫Well, let's see a first.
‫Remember, if in doubt, run the code, we'll make some data.
‫We'll go X equals and P random rand n and we want 1000.
‫What is rand?
‫Do shift tab.
‫Return a sample or samples from the standard normal distribution.
‫And what is a standard normal distribution?
‫Let's have a look.
‫Normal distribution.
‫Hmm.
‫We go here.
‫Okay.
‫And probability theory, the normal or Gaussian distribution is very common.
‫Continuous probability distribution.
‫Whoa.
‫That was a bit of a mouthful.
‫But what you really need to know is a normal distribution are these curves here.
‫So in the middle here, this is the main.
‫And the distance between the main.
‫And here is the variance.
‫And so whenever someone refers to a normal distribution, they're referring to one of these kind of
‫like symmetrical curves.
‫And they can appear anywhere on the x axis like this.
‫That's what you need to know about a normal distribution.
‫So if we go in here, this is going to make some 1000 random samples that would fit within this curve.
‫But if in doubt, run the code.
‫Let's actually see this in action figure.
‫X equals.
‫Because remember, every time we want a new plot, we create a new plot.
‫Subplots x hist x little semicolon at the end.
‫So what we've done here.
‫So we're doing a histogram, but oftentimes you'll see it shortened to hist.
‫So if you see hist probably referring to histogram.
‫So if we do that.
‫Ah.
‫There we go.
‫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.
‫That's what we're after.
‫Just that same shape.
‫Beautiful.
‫Okay, now we've covered histogram.
‫It's now what if you wanted to get multiple plots happening at the same time?
‫We've referred to this before as subplots.
‫Well, the beautiful thing is we can make them with the command we've been using.
‫Now, again, there's two options.
‫For actually histograms because you want to make this a bit more communicated and plot it.
‫There we go.
‫We're in the habit of being communicative, so we've got to finish off that cell before we start a new
‫one.
‫Two options for subplots.
‫Let's do that.
‫Make a little heading.
‫And then we'll go subplot.
‫Option one.
‫Wonderful.
‫Okay.
‫We're going to create FIG.
‫Now, this is going to look a bit different to what we've been doing, x1x2.
‫And you're like, Whoa, what's going on here, Daniel?
‫But don't worry, fall along.
‫And we'll explain it in a second.
‫Because remember, we're in the habit of just seeing what happens with the code and rose equals to hold
‫on.
‫We never passed a keyword argument to this and now we're going to pass three.
‫We're living dangerously.
‫I told you, fig size equals ten five.
‫Well, my five k is a bit sticky, you know, so if we look.
‫What is this actually doing?
‫Let's run it.
‫Whoa.
‫Look at that.
‫Now, can we infer what's happening here without even looking at the docstring?
‫So we've got fig comma and then a tuple which is of tuples of x1x2x3x4.
‫So can you guess what's happening here?
‫And we've got some keyword arguments in rows equals two and Coles equals two.
‫Fig size equals ten five.
‫What do you think's happening?
‫And rows equals two.
‫Two rows.
‫Two columns.
‫I've got x one, maybe x2x3x4.
‫Well, I think that would be pretty spot on, if that's what you guessed.
‫That's what I guessed.
‫So here we go.
‫Let's read.
‫Create a figure instead of subplots.
‫This utility.
‫Yeah, we've read that before.
‫And rose a number of rose columns of the subplot grid.
‫Beautiful.
‫Now, let's say, how would we get data on here?
‫So let's.
‫Let's do this plot to each different axis.
‫Let's see this in action.
‫X one dot plot.
‫Let's go x.
‫We've got some x data.
‫I think that'll probably do.
‫Let's see what happens when we do plot it.
‫Name, straight line.
‫Wonderful.
‫We can do that.
‫Okay.
‫So yeah, x one is this top left one.
‫Okay.
‫That's that makes sense because it comes first.
‫Can you guess which one is x two?
‫Well, let's see and find out.
‫MP Let's make some, some more random data.
‫Random random ten and we'll do randomly random again ten and semicolon.
‫Ah.
‫Okay.
‫And so we've created a little scatter here.
‫So that's X to wonderful x three.
‫Let's do a bar on this one.
‫We're going to start mixing this up, you know not.
‫But can I do tab complete not better prices.
‫Yes, I can dot keys not.
‫But we want the values on this $1 values.
‫Wonderful.
‫And let's see what happens.
‫Beautiful.
‫We're starting to fill out our subplot here.
‫This is wonderful, Axel four We want hist and then we want hm paid a random rand and normal distribution.
‫We take that out before.
‫There we go.
‫Boom.
‫Now we have a subplot with four different subplots.
‫Now, again, this is just some dummy data except for this.
‫This is real stuff right here.
‫This is Dan Zimmerman by the store.
‫And now you could add some titles to these axes, much like we've done up here with this set command
‫here.
‫But this is just to exemplify one way option one.
‫We'll do option two in a moment, maybe in the next video of how you can get more information on the
‫one figure.
‫So if we look back to our anatomy here.
‫It's still a big figure, this blue square.
‫If we converted this blue square, it's going to follow around this.
‫But now we've got axes, zero axes, one, axes, three axes, four.
‫But it's actually actually zero one, two, three.
‫But we've named them differently.
‫In reality, we should have probably zero indexes, but I've just gone one, two, three, four.
‫But now you're starting to see if you wanted to get more information, just one image, rather than
‫having four different figures.
‫You can see you can do that with subplots.
‫The reason why we've been using this command is that you can create single plots or multiple plots with
‫the same command.
‫That's that flexibility we were talking about of the object oriented API from that plot.
‫Lib So this is option one for the video gets too long.
‫We'll pause it there and we'll have a look at option two in the next one.