The Figure Object Video Lecture Transcript This transcript was automatically generated by Zoom, so there may be discrepancies between the video and the text. 13:37:10 Welcome back everybody. In this video. We're gonna learn about the map plot. 13:37:15 Lib. Figure objects. Let me go ahead and move over to our Jupiter notebooks so we can get started. 13:37:20 So remember, this is in the lectures folder and the python folder, and then finally, in the mat plot, live folder. 13:37:28 So we're gonna scroll down and you're gonna want to click on the figure object for me. 13:37:31 I'm gonna click on the complete version, because currently it's empty. 13:37:34 And then all you will fill it in as we go along. 13:37:37 You'll want to click on this version without any dashes afterwards. 13:37:43 So in this notebook, we're gonna create our very first mat plot, lib plot, and then we'll introduce the idea of the mat plot, live figure class. 13:37:52 So I'm just importing Matt Plotlob pi plot as plot. 13:37:56 So pi plot is the high-level Api that allows you to run functions, and then create map, Plotlib plots. 13:38:05 So we can make a plot first initiating a figure by calling plot figure. 13:38:12 Now, what is a figure? We'll talk more about this, and just a little bit. 13:38:16 So this is going to be our very first map. File, lib plot. 13:38:20 It's going to be a plot of a line. 13:38:21 Segments of the line, y equals x. So here it is, our very first mat plot web plot. 13:38:29 We did it where data, viz. Folks, we've made a database. 13:38:34 So we have our axes here, and then here's the line. 13:38:37 Okay, so what went on here was that map, plot, limb created what's known as a figure object. 13:38:45 This is the most basic element of a mat plot. Lib plot. 13:38:48 Now it's important to important to note this whole thing. 13:38:51 The plot itself is not technically the figure object. The figure object is what the entire plot is laying on top of. 13:38:58 So if we were in the 3D world. Sort of imagine, like, we put our figure objects like when you have a piece of art that you want to hang on the wall, you get a frame, and then you put the art inside of that frame the figure. 13:39:09 Object is kind of like the frame for the art for the Matt plot. 13:39:16 So the figure is a class within Matt plot. Lib. 13:39:21 This is gonna hold off our elements so we can just go ahead and make an empty figure object. 13:39:26 So we're gonna call plt dot figure. So this code right here, this function plot figure creates the empty figure object, and we can go ahead and even show that figure object but what we're gonna see now is this sort of weird thing figure size. 13:39:41 6 40 by 480 was 0 axes. Now this number maybe, is different for you, depending on the default settings of your computer for me at 6, 40 by 480. 13:39:50 But basically. What this is saying is we have an empty figure object. 13:39:54 There's nothing in it, and in a Jupiter notebook environment that's weird. 13:39:58 It doesn't understand what to do with that. Here is an example of what it would look like if you made it just using a terminal or a command prompt in a and python. 13:40:08 So it's just an empty screen. So like, imagine this same thing for your Firefox, right? 13:40:15 But there are no tabs. There's nothing on it. 13:40:18 So that's what an empty figure object looks like. 13:40:20 So basically what we would need to do is add stuff onto it, which we're gonna talk about more in the next notebook. 13:40:27 So we're gonna talk about a couple of things that you can customize with your figure. 13:40:33 So first thing is, you can give it an identifying number as Nu M. 13:40:39 You can also specify a size for the figure. So this specifies the width and height in inches. 13:40:47 But this I want to point out, that in within a Jupiter notebook it's not always strictly within inches, because the Jupiter notebook is restricted to this little display area. 13:40:57 Then finally, you can specify something called the dpi, which stands for the dots per inch, basically, this controls the resolution of your image. 13:41:05 So the default value is 100. If you're smaller than 100, you're going to have a lower resolution image, and if you're larger than 100, you're gonna have a higher resolution image and we're gonna go through some examples with fig size and dpi we want with 13:41:21 num because it's just a way for us to call our figure later. 13:41:23 So like you would do something like Plt. Figure Num equals 8 or something. 13:41:29 And then that figure from now on will be basically labeled as Figure 8 okay, so I'm gonna go ahead and change my fig size. 13:41:38 So fig size equals 8 comma 6. And we're gonna take a look at what this does to the empty object. 13:41:44 First. So here you can see. Well, now, my figure size is 800 by 600. 13:41:49 Remember in the old version the default was 640 by 40, so we've increased the size of our image. 13:41:56 Okay. So let me go ahead. And now put this back in there, and we can see that now we've made an image that's larger than what the default was which we had up here. 13:42:05 Okay, same plot. But now it's bigger, because our figure object is bigger. 13:42:09 We can also play around with the dots per inch. 13:42:12 The dpi. So let see what happens if we have a lower resolution image. 13:42:16 So Dpi equals 50. Okay? And within a Jupiter notebook, it's reflected as our our image getting smaller, I alternatively, we can make it larger. 13:42:27 So what if we double the default to 200? Well, now our image is bigger, but it's also a higher resolution. 13:42:33 Okay, so this is an effect of being in a Jupiter notebook. 13:42:37 If we are to save this to a file, then what we would see is a higher resolution image. 13:42:41 So that's really the basics of a figure object. 13:42:44 It's really good to have an understanding of what this is and what's going on. 13:42:48 It's the Matt Plot lib class that you then will add stuff to. 13:42:53 So we create a figure, and we don't always have to call Plt figure for this to work. 13:42:59 But I like to specify the figure at the beginning, so I know where my plot is. 13:43:03 Gonna end up. Then I put some stuff on it with Plot plot more on that. 13:43:07 In the next 2 notebooks, and then I display the figure, so the figure holds everything we can think of. 13:43:11 It, like the frame that we're gonna put stuff in. 13:43:15 Okay. Alright. So that's it, for the figure class. 13:43:19 We now have a good understanding of that. In the next notebook we're going to talk about something called the Axes Class, which is the stuff that we put inside the figure. 13:43:29 So going back to our art analogy, it's like the frame. 13:43:31 It's the print that you're gonna put inside of the physical frame. 13:43:35 Alright! So more about that. In the next notebook, though I hope you enjoyed this video.