Hello, guys, and welcome back to the class of our course about the complete introduction to the science
with Python.
So in this class, we are still going to talk about matplotlib and some other things that we can do
with this amazing add on to Python.
So basically what we are going to learn today is how to create a certain type of graph.
So basically, this is something that matplotlib can help you out with.
So basically it's used for a visualization.
So we will learn how to visualize our data with a bar graph.
So basically how to create a bar graph, you'll see it's pretty simple and it works pretty much the
same way as we saw it a little bit before.
All right.
So, as always, the first thing that we want to do right now is create our matplotlib.
So we'll just write down, import my blood, Leyb Dot.
So very important, try to not make a mistake by Plott.
As VLT All right.
So when it's all done, the next thing that we want to do is start start creating our craft.
So this is the first part of the creation of a graph is creating the database.
So in our case, what we will do right now is we'll create a graph with three functions inside of it.
So basically, we'll have three X's in three ways.
So pretty simple.
What we'll do right now, we'll just give a name to each of our variables.
So basically, we'll have X one, Y one, then X two.
Why two and finally, we'll have X three as well as white.
All right, so when everything is done, we'll just give certain values to our exes.
So in the first case, we'll have X one, which would be, let's say two for six and Y one would be
in this case, let's say three, six, nine.
So you don't have to do the exact same thing as me.
The numbers that I'm using are just random numbers to be able to just create a graph so you can use
the numbers that you guys want.
It's up to you.
So in this case, I'd say, why two would be five, 10, 15 and for extra, let's say it's going to
be six, 12, 18.
And while she is going to be 12, 24, 36.
All right, so until now, we have a database that is pretty simple.
So you can see we have three functions.
So we have enough data for three functions.
In our case, the next thing that we will do right now is putting everything together.
So basically, we are going to use the bar function in this case, because our goal, our goal is to
create a bar chart with a bar graph.
So how exactly will do this?
It's pretty simple.
So we'll write down our DOT bar.
So we start with this.
Then the next thing that we need to enter is the arguments that will be used inside of our bar graph.
So basically, what are the variables that will use?
In this case, we'll use the list right here in the list right here.
So we'll use X one as well as Y one this.
So this is for our first bar.
We'll do the exact same thing for the other ones.
So basically we have extra Y2 extra to watch.
So then you can just change the names.
And finally, XStream as well as White three.
All right.
So right now we have everything that we need to be able to create our graph.
So the last thing that is left to do right now will be to add a title as well as a title for our access.
So we'll write it down.
So Kielty that title, this is the first step.
So give a title to our graph.
Let's call it test graph one.
So this would be our graph title and then plot that X label.
So in this case, let's call it test X name, and the next thing and the exact same thing will do for
our Y y axis.
So.
All right, already done that Y label.
And for our y axis will write the exact same DNA test y name.
All right.
So right now we have our exes and we have our weisse.
So right now, everything is amazing.
We can run our our a graph and see what it looks like.
So very important to make up for mistakes.
So especially for the little mistakes right here, because if you don't do it, you can have an error
message.
So finally, to run, everything will just write down Kielty show we open and close parentheses and
we can run everything.
So as you can see, we have our graph right here which shows us how everything works.
And as you can see, it's pretty cool.
So basically, we have our right there.
We have our X1 x2 as well as Extra.
So everything is inside of this graph and it's pretty nice.
All right.
So another thing that we can do right now is change the style of our graph.
So basically, if we want to change the style of our graph, it's like always so we will need to import.
In this case, we will import the style stuff package.
So how exactly would this it's pretty simple.
So we'll just write down the import style.
So we need to import stuff from matplotlib.
So done from Matt Leyb import style.
And what we can do right now is we can change the scale of our graph, so it's pretty simple.
We'll try it out, we'll just write down style use.
So is the right here.
I'm changing the style of my graph and let's say we want to use the in each style, so we'll call each.
So this is a style type that exists so we can run everything.
And as you can see, the style of our graph just changed.
So it's a bit different.
So everything works.
We have the title of our graph here, the title of each axis, and finally the style of our graph that
just changed.
So if I'm making a quick interpretation of the code, so basically the first part right here is where
we imported all the packages, as well as a sub package that we needed.
The first part right here is the style that we want to use for our chart here.
We have our database.
So our database is right here.
Here we have everything that we put together.
So basically, we're creating the first function, the second one, as well as a third function right
here with the use of our database.
And finally, right here, we are giving names to our chart as well as to our axis.
So basically the X and the Y axis.
So I hope you guys understand how to create a well, this type of graph, which is a bar graph, and
I hope that you will be able to use it in the future.
So that's it for us.
Thanks, guys.
And see our next class.