Week 3 code

Hello Team need some help please
What do the following functions mean ? -
plt.close(‘all’)

The `close('all')` just closes all existing figures. It needed to tell the plotting library that you’re finished setting up the existing figures. See this documentation for more info.

The `plt_one_addpt_onclick()` is a custom function written by coursera staff. It generates the plot you see below, and allows you to add points to the graph by clicking. You can see the code for this function in one of the other files in the assignment. Choose `File``Open` from the menu bar and select one of the util files. The implementation should be in one of those.

Thank you why cant we use the plt.plot function instead.
Is there more documentation available on plt_one_addpt_onclick. I cant find it anywhere. Need to understand why are we using this function versus others ?
Thank you

Hi Team

Quick question - What does the x0 = np.arange(0,6) function do here, how its reflected in the graph ? Thanks

DLAI staff

The `plt_one_addpt_onclick` is a custom function in one of the assignment util files. Choose `File``Open` from the menu bar and select one of the util files. The implementation should be in one of those.

I’m pretty sure `plt_one_addpt_onclick` uses `plt.plot` to plot the actual graph.

1 Like

Hello @Jasmine7

plt_one_addpt_onclick is class function recalled by the programmer or the coder who designed this assignment. it is not universal documented function.

For example:
“”" class to run one interactive plot “”"
def init(self, x, y, w, b, logistic=True):
self.logistic=logistic
pos = y == 1
neg = y == 0

You can find similar plt if you search on google.
Why we are using this function versus others in because we want to plot a graph of the data available in a linear regression analysis.

The reason this was use over others, I would say is to have an understanding on the data is spread in this linear relation, or any regression analysis.

Regards
DP

1 Like

Hello mentors any reply for the x0=np.arange(0,6) above, how is it being used in the graph ?

The above code is not from week 3 assignment, so kindly share screenshot from where you have got the codes.

Regards
DP

Because the plot is actually an interactive window.
If you don’t need interaction, you can just use the regular plot functions.

1 Like

For the first part of your question, you can easily answer this yourself by looking at the numpy documentation to see what the arange() function does.

https://numpy.org/doc/stable/reference/generated/numpy.arange.html

Or, you could do your own experiment:

For your second question, the x0 values are the x-coordinates for which the plot is going to be made, using the equation “x1 = 3 - x0”.

1 Like

Thank you so much TMosh. Very helpful, really appreciate the explanation