 Now in the previous video you may have noticed I only used map plot lib I wasn't really mixing it with numpy and well, you know, we've used numpy to create Polynomial functions of polynomial curves and we've used map plot lib to plot data Well, what happens if I took these two things and? Merge them together and that's what I'm gonna do for this little video So I'm going to kind of do the refresher on Finding a curve with numpy and Working through that so again I'm going to have to start by creating my curve with the numpy poly fit function and again It just asks for an accent in a Y fantastic and Again, I always like to confirm what I'm doing so I'm gonna just come in with a print statement to print my curve So I run this I Always forget that So one of the things that I need to do is I do need to make sure that I'm Creating what level of polynomial in this case. This is a second degree polynomial function Now I run it and that's what we see we see the same data again perfectly fine Fantastic, so we're going to continue with that same idea now. I'm gonna turn this numpy array into a polynomial function So I'll create it again as poly and I'll go numpy Poly 1d on that curve that I just created once again just because I always do this I'll make sure to print out my value that way. I can confirm what I see and again I should just see that these numbers right here Get printed attached to X's at various power levels. Awesome. Fantastic. We're great So now with this I want to create new data that is going to effectively plot out the curve And I'm going to go ahead and name two new variables new X and New Y now I'm creating them as lists more specifically because I'm going to be adding to them And I could be using the the X that I've done before but since I'm using I'm creating new data And I'm going to be working with sort of new data. I always like to make new variables I don't want to manipulate X because then I may screw that up somewhere down the line So in my case, I'll go in with a for I in range we'll start with 20 since we're dealing with 20 numbers and New X will simply that appended. I I plus one So one to 20 nothing terrible nothing crazy nothing outlandish simple But you might remember that the Poly 1d function is going to create a polynomial function and that means that poly is a function So if I came in and just did something like poly I plus one for example And I run this I see a bunch of numbers because I'm seeing what happens when I replace the X in This formula with a one. What do I get? Well, I get sort of this value And it's not you know necessarily a one because again, we're not saying well What's the value in the Y axis? What we're saying is what if I plugged in on this curve that I'm Expecting the visuals I visualize if I plugged in an X equals one then this is the value This is the the point that would be on the curve Okay, fantastic. So I want to take these numbers And I want to set them equal to I like to call it calc. I'm calculating a value So I always kind of work off of that from here. This is where I want to go ahead and new y dot append my data so From here, I'll go in and just as always I like to print out my data to confirm everything that I'm seeing and Okay, so again, this is why I love print statements because they always even though I'm thinking it's one thing You know talking a mile a minute and I may accidentally make mistakes That just is human nature and in my case What happened was I appended of why and if I sort of just kind of look at what my variables are doing why is a list of numbers And if we look at what I just printed out, I've just printed out a list of a list of numbers So, you know, this is again where print statements are beneficial because then you can say oh, no I had a mistake. Let me fix my mistake Before it gets into you then you don't know where the mistake happened So in my case go in fix that y to be my calc And now when I print it Exactly what I should see all those numbers that we had printed on their own lines now They're printed inside of a list beautiful Fantastic, so what we can do with this is now I have an x. I have a y Well, I already know how to plot with Matt plot lib. So let's plot so I'll come in And I'll say PLT plot my new x and my new y and I was again, I know spider will show it for me, but just in case you're not using spider you're using some other programming Or development environment. That's not spider. I dole to blunt text whatever I also still like to make sure I do the dot show because that that's more of the way to Explicitly show it. So again, I'll go ahead and run this and when you know it There's my curve, but suddenly now it's so much smoother. Oh beautiful What's really crazy is we can actually start to add in multiple Graphs or visualizations onto the same graph. So as of right now, I've just got my curve going on there, but PLT dot scatter x and y So what this is going to do is it's first drawing my curve then it's gonna say well go through the data points on x and y and Plot them in a scatter plot diagram. So if I run it this time You can see that that's exactly what's happening my curve And then each one of my data points and as you can see the data points were much more narrow Going up and then going down the curve being a curve. Ah Nice and smooth What's really fun is this is where you could start to Really play around with your data because I sort of know what happens when you know X equals 10, you know, even if it's not going to be explicitly 10 It's gonna be close to 10. It'll be again. It was like a eight point something But what happens if I start to expand my data? Well, what happens if you know What would the curve sort of look like if I'm looking for x at 21 or 22 or 50? or 100 And if I curve if I plot this curve out you start to see I'm seeing my data points But if you imagine what was going on the apex at about the you know Exequaling 10 11 spot and then they slowly decline as x increases This is the trend that we were seeing Effectively is as exit increases after 10 it starts to slope downward and if we were to continue To increase x it just continues to slope down We can actually do the same thing on the opposite end So if I came in say for example this time and did negative 100 to 100 now I'm saying go to negative 100 all the way to 100. I Plot this out You see that I'm seeing that exact same curve going on here So funny enough interestingly enough it goes down harder on this end for the same amount of values But all right, you can start to see oh well. There's our apex So it's a way for you to start to take your numpy values and your map plot lib Visualizations and start to merge these points together and create something new