‫Welcome back.
‫So now we're really going to step it up a notch.
‫We're going to see the full power of the map.
‫Plot lib.
‫Object orientated method.
‫We're going to build upon what we've done here.
‫So we've created this this heart disease and cholesterol levels with our over fifties data frame.
‫But now we're going to add a subplot to this so we can visualize cholesterol levels and we might get
‫out over 50 data frame here so we can stop having to scroll up.
‫We're going to combine that with fellow act, which is I'm not sure if I'm pronouncing that by the way,
‫either fail atch, which is max hot, right?
‫So we want to have a subplot where we've got cholesterol and fell h on the y axis, but they're both
‫going to have age as the x axis.
‫So let's see that in action.
‫We want we'll toggle this subplot of call age.
‫They'll etch beautiful.
‫Well, we want to go here.
‫We're going to recreate this.
‫We could copy and paste this code.
‫But again, we want to practice writing from scratch, so let's see it in full force fig.
‫We want to use the object orientated method.
‫Now if you've had a go at creating a subplot on your own, this is the way you might have used.
‫But if not, this is how I would create a subplot of these two.
‫So remember, we want two different axes.
‫So Fig ax, zero and ax.
‫This is going to be acts one.
‫There we go.
‫So what this is saying is now we're creating a single figure, but it's going to have two axes on it.
‫Remember, axes are this here Y and X where you can add data.
‫So let's use the same commanders before subplots and we want to end rows equals to we want Nicole's
‫is going to be one.
‫Our previous figure size was ten and six.
‫But let's make this tan and tan, see what that looks like.
‫And now we want to go add data to X zero.
‫Actually, let's see what this looks like before we even plot.
‫Fig size oop.
‫Forgot an equal there.
‫Beautiful.
‫So now I've got two blank canvases to start adding our data on here.
‫So we want to add data to access zero, which is this one here.
‫So just going to be this exact same as before.
‫We'll do something like this.
‫So now we're going to add some data to Axis Zero, just like we've done up here.
‫We're going to do something similar to this.
‫But again, we're not copying and pasting.
‫We'll do it from scratch.
‫So we want scatter equals x zero dot scatter and we're going to go X is going to be the over 50 page
‫column.
‫Y equals over 50.
‫And this is going to be just a collateral column.
‫Beautiful.
‫And then we're going to go see equals.
‫We're going to color it with the zero 50 Target column.
‫Now, let's see what that looks like.
‫Beautiful.
‫We've seen this before, so customize x zero and we want to go x zero dot set and we want to add a title.
‫This is going to be heart disease and cholesterol levels.
‫Wonderful.
‫And then we want an X label which is going to be age and then we want to go Y label, which will be
‫cholesterol.
‫Nothing new here.
‫We've seen this before, but now it's only on axis zero, which is amazing.
‫Maybe we add.
‫Add a legend to ax zero.
‫Same code as a 40. legend scatter.
‫Not legend elements.
‫And then we're going to go Title Eagle's Target.
‫Beautiful.
‫What did we have up here?
‫We had a main line, so that's what we can do with the line.
‫So add a mean line.
‫So we're just replicating the plot we've done before.
‫Accident zero dot x h line.
‫Now we need to pass each line of y.
‫So we want over 50.
‫It's going to be the cholesterol.
‫So we'll do all.
‫Dot main and then we'll add a line style as.
‫Dash.
‫And that.
‫Should be.
‫The same plot as well we've got above.
‫But now it's on a subplot.
‫So.
‫I want to challenge you to before we go through it.
‫See if you can replicate what we've done here.
‫But with the Fell Ash column instead of the cholesterol column on this subplot here.
‫We'll give you a second.
‫All right, if you had a go.
‫All good.
‫If not, let's go through it.
‫So now we want to add data to X one, because remember, we've got x one up here.
‫Excellent.
‫Same thing we've done as before.
‫But this time, all we're going to do is change it from x zero to x one.
‫And then, of course, the column will be different.
‫All the data that we use will be a little bit different.
‫So in this case, it's one X.
‫The X is still going to be the age column.
‫What's going to change is what's on the Y axis.
‫So we have over 50.
‫They'll latch.
‫Wonderful collar is going to be the same because we're focused on our target variable, which is whether
‫or not the patient has heart disease.
‫So there we go.
‫Let's see what this looks like.
‫Okay.
‫So we're starting to get somewhere now.
‫We've got some data on both our accesses.
‫Let's customize it just like we've done with Access zero.
‫I'm going to do that with x1x1 point set.
‫Let's add a title.
‫Title.
‫This one will be heart disease and max heart.
‫Right?
‫Wonderful.
‫And then we're going to go X label can remember what that is just the age because we're using the same
‫column for the X now the Y label this is going to be flash ash.
‫So we'll actually put in Max Hot, right, because we want it to be a bit more communicative than just
‫fell out.
‫So if someone came and had a look at our plot and didn't know what Flash meant, they'll know.
‫It means max heart rate.
‫OC starting to make some progress now.
‫We still have a couple more things to do.
‫We want a similar set up to what we've got here.
‫So let's add a legend to ax one ax one belt legend.
‫Now again, we're creating quite similar plots here with the subplot that we're making.
‫So these two are quite similar.
‫As you've seen before, you could have a scatterplot here and you could have a histogram here or something
‫like that.
‫But we're just using this as an example.
‫So title equals target 1 to 4.
‫We'll add a main line as well.
‫So x one dot x age line now we're going to color it with the Y is going to be this time instead of cholesterol,
‫it's going to be they'll match 1 to 4 dot main and then the line style.
‫We're going to keep it with our trusty dash and then we'll add a semicolon here and let's have a look.
‫What have we messed up?
‫We got an error line.
‫2D has no property line style.
‫This is classic typos everywhere.
‫Here we go.
‫So it's okay to make errors, right?
‫You're never going to type out all the code correctly every time.
‫The first time.
‫Beautiful.
‫This is starting to look really good.
‫Okay.
‫What we're starting to see, we've got an age x axis label here, but this is also age, so maybe we
‫could tell them to share the x.
‫So let's see.
‫Where can we add that?
‫Maybe I've been here.
‫I want to share the x.
‫So share x equals true.
‫But now we can remove this label on axis zero.
‫So what is this going to do if we put in share x equals true?
‫What do you think?
‫There we go.
‫So what this has done is it's telling our plot to go that our subplots here have the same X value.
‫So we don't need to put in the age label there.
‫Maybe you would keep it in there for a bit more.
‫So it's a bit more communicative.
‫That's kind of one way you can start to clean up your plots.
‫And now what we might do is add a title to this overall thing.
‫So we've got both subplots, a title, but we might want a title, the entire figure.
‫So let's see how we do that.
‫Add a title to the figure.
‫Now, this is Fig, because remember, we've created a figure and we've added data and customization
‫to the accesses.
‫But now we want to start to access the figure directly, which is that big blue square on our map plot
‫lib anatomy.
‫We filled up these two and our subplots.
‫Now we want to title our figure so we can do that with fig dot sup, which is stands for I think it
‫stands for Super Title.
‫I actually don't know what SUP stands for.
‫I just know that it's subtitle and then we go heart disease.
‫Analysis and we'll create the font size.
‫We want it to be pretty big font size and a font weight of bold.
‫We'll put it semicolon at the end.
‫Beautiful.
‫Look at this.
‫Maybe we have to zoom out a tiny bit so we can see it all in one hit.
‫There we go.
‫You know, you starting to see what this is kind of looking like.
‫Remember, right at the start in the concept lecture, we looked at the anatomy of a map plot live figure.
‫We looked at that plot and it was quite complex.
‫There's a lot going on.
‫Well, what you've done is you've just followed along and recreated something very similar.
‫Now, what we're going to do in the next video is style this a little bit better.
‫So fix up some of the colors.
‫The important thing to remember is it looks like a lot of code here.
‫It actually is.
‫We've got.
‫25, 30 lines of code there.
‫But what we've done is we've built this figure from scratch using the object orientated map plot lib
‫method.
‫And so now what seemed at the start to be a very complex and complicated plot.
‫It's actually just quite simple, right?
‫You create a figure, you create a couple of accesses, you add data to the accesses, you add some
‫customizations like titles and a legend and a horizontal line, and you start to get something looking
‫like this.
‫Now, that's something that you could put in a demonstration or show your colleagues in a presentation,
‫something like that.
‫Right now you're starting to see just how powerful map plot lib the object orientated API can be.
‫All right, let's wrap this video up, have a practice, maybe create your own subplot without a scatter,
‫try a histogram and maybe a bar graph.
‫Can you do that on the same figure?
‫Otherwise, I'll see you in the next video and we'll learn a little bit more customization of these
‫plots.