Initiating a figure with plt.figure()

The plt.figure() API is the API that is used to initiate a figure that serves as the base canvas. It takes in arguments that determines the number of figures and parameters such as size and background color of the plot image. It displays a new area as the canvas for plotting axes when called. We wouldn't obtain any graphical output unless we add other plotting elements. If we were to call plt.show() at this point, we would see a Matplotlib figure object being returned, as shown in the following screen capture:

When we are plotting simple figures that involve only a single plot, without the need for multiple panels, we can omit calling plt.figure(). If plt.figure() is not called or if no argument is supplied to plt.figure(), then a single figure is initiated by default, equivalent to plt.figure(1). If the dimension ratio of a figure is crucial, we should adjust it by passing a tuple of (width, height) as the figsize argument here.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.117.233.160