In line 20 a method is being called on the object ax. The method is It is being given 1 argument: The imshow(). img. imshow() method is being called on the object. Since is an instance of the ax ax AxesSubplot class, must be a method of the AxesSubplot class. imshow() Similarly, in line 22, the method _______ is being called on the object ________. That method is being given ___ arguments. That method is a method of the class _________. Comments help us undestand why a method is called. Which comments explain which lines in the code above? Part IV: Arrays of Objects Methods return data. Calling returns a tuple of two subplots(1, 1) objects: (Figure, AxesSubplot) The method subplots can also be used to create a grid of AxesSubplots, as shown below. In this case subplots (1, n) will return (Figure, ndarray of AxesSubplots) where ndarray is an n-d array, short for an "n-dimensional array." You can access the elements of an ndarray with an index in square brackets: 17 # Create a 1x2 grid of subplots 18 # fig is the Figure, and ax is an ndarray of AxesSubplots 19 # ax[0] and ax[1] are the two Axes Subplots 20 fig, ax = plt.subplots(1, 2) 21 # Show the image data in the first subplot 22 ax[0].imshow(img, interpolation='none') 23 # Show the figure on the screen 24 fig.show() Modify lines 18 and 20 of your code to match what is shown above. You will have to re-execute the code to see the effect. Practice using object-oriented
In line 20 a method is being called on the object ax. The method is imshow(). It is being given 1 argument: img. The imshow() method is being called on the ax object. Since ax is an instance of the AxesSubplot class, imshow() must be a method of the AxesSubplot class. Similarly, in line 22, the method _______ is being called on the object ________. That method is being given ___ arguments. That method is a method of the class _________. Comments help us undestand why a method is called. Which comments explain which lines in the code above? Part IV: Arrays of Objects Methods return data. Calling subplots(1, 1) returns a tuple of two objects: (Figure, AxesSubplot) The method subplots can also be used to create a grid of AxesSubplots, as shown below. In this case subplots (1, n) will return (Figure, ndarray of AxesSubplots) where ndarray is an n-d array, short for an "n-dimensional array." You can access the elements of an ndarray with an index in square brackets: 17 18 19 20 21 22 23 24 # Create a 1x2 grid of subplots # fig is the Figure, and ax is an ndarray of AxesSubplots # ax[0] and ax[1] are the two Axes Subplots fig, ax = plt.subplots(1, 2) # Show the image data in the first subplot ax[0].imshow(img, interpolation='none') # Show the figure on the screen fig.show() Modify lines 18 and 20 of your code to match what is shown above. You will have to re-execute the code to see the effect. Practice using object-oriented