Welcome back.
We used numpy to generate random numbers.
Also we created two variables size and price.
Size depends on random numbers and price depends on size.
With this linear relationship between size and price.
Also, we converted numpy array into a pandas data frame table like structure.
Using this PD pandas dot data frame, and we concatenated the size and the price to draw and create
this table.
The size and the price.
Those are random generated numbers.
Now let's visualize the relationship here.
We're going to use matplotlib.
Start with plt dot figure.
And here set the figure size equals to eight by five okay.
This creates a new figure creating Creating.
And you figure the plot window.
The figure size sets the width to eight inches and height to five inches.
So here with five and eight inches.
Five inches.
Okay.
If we run the code, we have the figure size 800 with 500 with zero axis.
So we need to set this axis.
Clear the input and output.
Sorry.
Now we're going to plot a scatter plot or dots.
So plots plotting set plt dot scatter.
What data we need to use.
We need to use the data size.
So data we need to get the size which is this.
So we are going to get this column the size.
And remember we stored all the data inside the data variable.
So we need to access the data variable.
How to access it?
We specify its name and we specify inside the angled bracket the column that we need to display.
This is the first one.
This is the first axis.
The second axis which is the y.
So the first the first variable is the x axis.
The second one is the y axis.
Starting with data, the price and set the color blue and label data points okay, this plots a scatter
plot dots with x the size and the y axis the price.
The color dots are blue and the data data points used in the legend.
Okay, now if we run it, we have those dots.
Okay.
So here we have this figure eight by five inches.
We have the 100 dots around 100 dots because we are not getting the first ten in order to get the first
ten data.
Here we need to set it inside the scatter.
So let me make it like this.
In order to get and use the head.
Head ten to get the first ten.
Head ten.
Run it again.
And here we go.
We have only the first ten results from the data set that we get.
So since we are getting the first ten size and the prices, we need to plot them here inside this figure.
Now we can add a title at the top of the plot.
So PLT the plot dot title house house size versus price.
Also, we can set the label for the x axis to tell the user that this is the size in square feet and
the y label.
This is in thousand dollars.
Also, we can set a legend, a grid view and to show it.
So here we have this grid in order to add the plotting to this copy or cut this and paste it here.
Cut the code, paste it here.
Use the copy selection not copy and paste it here okay.
Delete this cell.
And here we go.
Now we're going to display the same output but with grids and legend.
Run it again.
You see the grids.
You see the label size and the price.
You see the legend here.
And the dots are inside this grid.
So this is a very important thing to visualize and plot the data on this chart.
So in this video we learned how to plot a scatter a scatter plot, how to create this diagram showing
the points and the results of all the first ten random generated results.