Explanation of graph plot

Hi

According to this command ‘plt.scatter(x[:,0],x[:,1],c=y)’, on x-axis there are elements from 0th column and on y axis elements are from it’s 1st column. Then how these plots are related and marked through Y array using c=y, please explain in detail.

for full code you can refer to this video lecture, I have followed same approach with same variables as shown in this lecture.

Hey @pasta, there are two parts in this scatter plot,

Considering dataset for dog height and weight. We you have 2 columns in X matrix, for the time being say first column belongs to weight and second feature belongs to height and you want to display a scatter plot between weight ans heights with weights on x axis and height on y axis.

x coordinates = X[:,0] # means all rows in X matrix but only the first column i.e. weight of all dogs
y coordinates = X[:,1] # means all rows in X matrix but only the second column i.e. height of all dogs

this will put first column on x axis and second column values on y axis
plt.scatter(X[:,0], X[:,1])

Now comes the second part. where c= y. Now lets say our dataset contains data for two breeds of dogs, Lebra denoted by 0 class, and Husky denoted by 1. Now if just plot using plt.scatter(X[:,0], X[:,1]) than all points will be of same colour, and we will not be able to distinguish this point belongs to which category. So we used c = y and plt.scatter itself assigns color encoding meaning say it assigned 0 as yellow and 1 as blue than each point which has y=0 will be shown on graph using yellow color i.e. Lebras will be shown using yellow and those with y=1 will be shown using blue color i.e. Huskies will be shown using Blue.

HOpe this resolved your doubt.
Plz mark the doubt as resolved in my doubts section. :grinning: