Welcome back.
Hopefully you've created your own graph here and 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 X equals plot dot subplots and we go axe DOB bar Hage for horizontal we're going to
pass it just the exact same thing as above now.
But our prices dot ks and nut but because we've got our saved dictionary up there.
Yours might be a different name dot values.
Oh what's happened here.
Uncatchable type decays.
Mm 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 had I find that well I did our search method I looked it up pre banked 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 I
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.
Now let's check out.
What have we done so far.
We've done line we've done scatter we Dunbar let's do his diagrams what's a histogram.
Well let's see I first remember.
If in doubt run the code I'll make some data we'll go.
X equals and paid a random dot Rand in and we want a thousand of what is Rand end to shift tab.
Return a sample or samples from the standard normal distribution.
What is this standard normal distribution.
Let's have a look.
Normal Distribution
go here.
Okay.
In probability fearing the normal or Gaussian distribution is very common continuous probability distribution.
Well 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 a 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 a thousand random samples that would fit within this
curve.
But if in doubt run the code let's actually see this in action.
Fig X equals because remember every time we want a new plot we create a new plot subplots X dot hist
X little semicolon at the end.
So what we've done here is we're doing a histogram but oftentimes you'll see it shortened to hist so
you see hist probably referring to histogram.
So if we do that huh.
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 is 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 histogram 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 you're gonna finish off that cell before we suddenly 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 gonna look a bit different to what we've been doing.
AX 1 ax 2 new light wall what's going on here Daniel.
But don't worry.
Follow along and we'll explain in a second because remember when the habit of just seeing what happens
with the code and Rosie goes to hold on.
We never passed a keyword argument to this.
Now we're gonna pass three living dangerously I told you.
Big size equals ten five.
Well my five key is a bit sticky you know.
So if we look what is this actually doing.
Let's run it
look at that now can we infer what's happening here without even looking at the doctoring so we've got
fig comma and then a tuple which is of tuples of x 1 x 2 acts 3 X 4.
So can you guess what's happening here and we've got some keyword arguments and rows equals two and
Coles equals two fig size equals 10 five.
What do you think's happening.
And rows equals to two rows two columns.
I've got X one maybe x two x three x four.
I think that would be pretty spot on if that's what you guessed.
Said I guessed.
So here we go.
Let's read create a figure instead of subplots this utility.
Yeah we've read that before.
And rows number of rows columns of the subplot grid beautiful.
Now let's see how would we get data on here.
So let's let's do this plot to each different axis.
Let's say this inaction asks one dot plot.
Let's go to X you've got some X data I think that'll probably do.
Let's see what happens when we do plot it bam straight line.
Wonderful.
We can do that okay.
So yeah x 1 is this top left 1.
Okay.
That's that makes sense because it comes first.
Can you guess which one is x 2.
Well let's see and find out empty.
Let's make some some more random data.
Random random 10 and we'll do random random again 10 and semicolon huh.
Okay.
And see we've tried a little scatter here.
So that's x 2 wonderful x ray.
Let's do a bar on this one.
We're gonna start mixing this up you know not but can I do tab complete.
Not better prices.
Yes I can.
Doug K's not but we want the values on this one dollar values.
Wonderful.
Let's see what happens.
Beautiful we're starting to feel an alpha subplot here.
This is wonderful access for we want haste and then we want and paid a random grand and normal distribution
we take that out before there we go.
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's arm about a store and now you can add some titles to these actresses much like we've done
up here with this set command here.
But this is just to exemplify one way.
Option one would 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.
Now you're starting to see if you wanted to get more information just one image rather than having four
different figures you can say 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 for map plot lib.
So this is option one for the video I guess too long will pause it there and we'll have a look at option
2 and the next one.